> ## Documentation Index
> Fetch the complete documentation index at: https://docs.brew.new/llms.txt
> Use this file to discover all available pages before exploring further.

# Send Your First Email from Code

> Call the Brew API with curl to generate an on-brand email and receive a test in your inbox when you are new to the Public API.

In about five minutes, you will generate an on-brand welcome email with the Brew API and receive it in your own inbox.

<Note>
  Before you begin, sign in to Brew and finish [adding your brand](/get-started/add-your-brand). Wait until brand extraction is complete. You do not need to verify a sending domain.
</Note>

<Steps>
  <Step title="Create an API key">
    Open [brew.new/settings/api](https://brew.new/settings/api). Make sure the brand you just added is active, then click **Create API key**.

    Name the key `First email tutorial` and create it. The key receives the full permissions for the active brand. Copy the key when Brew shows it.

    The new key appears in the API key list for the active brand.
  </Step>

  <Step title="Check the connection">
    Replace `brew_your_api_key` with the key you copied, then run this command:

    ```bash theme={null}
    curl "https://brew.new/api/v1/brand" \
      -H "Authorization: Bearer brew_your_api_key"
    ```

    The response describes the brand bound to your key. Confirm that it contains `"ready": true`:

    ```json theme={null}
    {
      "brand": {
        "brandId": "kx7b3s7fapqz8mjm12ekz1kxdx87yceg",
        "domain": "example.com",
        "status": "completed",
        "ready": true
      }
    }
    ```
  </Step>

  <Step title="Create a welcome email">
    Use the same API key in this command:

    ```bash theme={null}
    curl -X POST "https://brew.new/api/v1/emails" \
      -H "Authorization: Bearer brew_your_api_key" \
      -H "Content-Type: application/json" \
      -H "Idempotency-Key: first-email-generate-001" \
      -d '{
        "prompt": "Create and save a welcome email for new customers. Use the subject line \"Welcome aboard\", the headline \"Welcome aboard\", a warm two-sentence opening, and one button labeled \"Get started\"."
      }'
    ```

    Brew returns `201` after it saves the design. Copy the `emailId` from the response:

    ```json theme={null}
    {
      "emailId": "eml_2SmZOWV3ZQ7W5x6g3m4p",
      "emailVersionId": "emv_2SmZOWV3ZQ7W5x6g3m4p_v1",
      "html": "<!DOCTYPE html>..."
    }
    ```
  </Step>

  <Step title="Send a test">
    Replace `eml_2SmZOWV3ZQ7W5x6g3m4p` with the `emailId` you copied and replace `you@example.com` with your own email address. Use the same API key again:

    ```bash theme={null}
    curl -X POST "https://brew.new/api/v1/sends" \
      -H "Authorization: Bearer brew_your_api_key" \
      -H "Content-Type: application/json" \
      -H "Idempotency-Key: first-email-test-001" \
      -d '{
        "test": true,
        "emailId": "eml_2SmZOWV3ZQ7W5x6g3m4p",
        "subject": "Welcome aboard",
        "to": "you@example.com"
      }'
    ```

    Brew sends the test immediately and returns this response:

    ```json theme={null}
    {
      "status": "sent",
      "recipient": "you@example.com"
    }
    ```
  </Step>

  <Step title="Open the email">
    Open your inbox and select the message with the subject **\[TEST] Welcome aboard**. Test sends carry the `[TEST]` prefix, so the subject you set arrives with it in front.

    You should see the generated welcome email and its **Get started** button.
  </Step>
</Steps>

## What You Just Did

* Proved that a brand-bound API key works.
* Created and saved an on-brand email over raw HTTP.
* Sent the result to a real inbox without a verified sending domain.

## Keep Going

* Use the official client in the [TypeScript Quickstart](/sdks/typescript/quickstart).
* Generate a client for another language with [OpenAPI Codegen](/sdks/openapi-codegen).
