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

# Generate Email

> Generate a draft email from a natural-language prompt

# Generate Email

Generates a draft email from scratch as structured editor-compatible blocks.
By default, Sequenzy wraps the generated content with your company's email
branding: branded presets include a logo and full footer, while minimal presets
include a simple footer. Review the returned blocks before creating or sending
a campaign.

## Request

<ParamField body="prompt" type="string" required>
  What you want the email to say or accomplish.
</ParamField>

<ParamField body="style" type="string">
  Optional style guidance, such as `minimal`, `branded`, or `promotional`.
</ParamField>

<ParamField body="tone" type="string">
  Optional tone guidance, such as `professional`, `casual`, or `friendly`.
</ParamField>

<ParamField body="applyBranding" type="boolean" default="true">
  Whether to wrap the generated content with your company logo and footer. Set
  this to `false` to return only the AI-generated content blocks.
</ParamField>

<ParamField body="emailType" type="string" default="marketing">
  Email type: `marketing` or `transactional`. Transactional emails include a
  footer without an unsubscribe link.
</ParamField>

```bash theme={null}
curl -X POST "https://api.sequenzy.com/api/v1/generate/email" \
  -H "Authorization: Bearer seq_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Announce our new analytics dashboard to trial users",
    "style": "branded",
    "tone": "friendly",
    "emailType": "marketing"
  }'
```

## Responses

<ResponseExample>
  ```json 200 theme={null}
  {
    "success": true,
    "subject": "Meet your new analytics dashboard",
    "previewText": "A clearer way to track what matters",
    "blocks": [
      {
        "id": "block-logo",
        "type": "logo",
        "alt": "Acme Logo",
        "align": "center",
        "width": 64
      },
      {
        "id": "block-heading",
        "type": "heading",
        "level": 1,
        "content": "Meet your new analytics dashboard"
      },
      {
        "id": "block-footer",
        "type": "footer",
        "variant": "full",
        "companyName": "Acme",
        "address": "123 Main St"
      }
    ],
    "message": "Generated a draft email."
  }
  ```

  ```json 400 theme={null}
  {
    "type": "validation",
    "on": "body",
    "property": "/prompt",
    "message": "Expected string"
  }
  ```

  ```json 401 theme={null}
  {
    "error": "Invalid API key"
  }
  ```

  ```json 403 theme={null}
  {
    "error": "No companies found. Create a company first using the create_company tool."
  }
  ```

  ```json 500 theme={null}
  {
    "error": "Failed to generate email"
  }
  ```
</ResponseExample>
