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

> ## Agent Instructions
> Automate.ax automations are TypeScript programs.
> Use Bun for installation and command examples.
> Use Automate.ax for the product name and automate.ax for the package, CLI, and domain.
> Treat documented public APIs as current; do not invent transitional or deprecated names.

# Draft email

> Create an unsent Gmail draft for review or later completion.

`draftEmail` creates a message in Gmail without sending it. Use it for approval
flows, human review, or messages that will be completed in Gmail later.

## Example

```ts automations/draft-follow-up.automation.ts theme={null}
import { automation, onHttpRequest } from "automate.ax"
import { draftEmail } from "automate.ax/gmail"

export default automation("Draft a customer follow-up", () => {
  onHttpRequest({ scope: "automation" })

  draftEmail({
    to: "customer@example.com",
    subject: "Following up",
    text: "Hi! I drafted this message for review before it is sent.",
  })
})
```

Recipients, subject, and body are all optional, so the action can create an
incomplete draft.

## Inputs

| Input         | Type                                              | Required | Default               | Description                                       |
| ------------- | ------------------------------------------------- | -------- | --------------------- | ------------------------------------------------- |
| `to`          | `Recipient \| Recipient[]`                        | No       | None                  | Primary recipients.                               |
| `subject`     | `string`                                          | No       | `""`                  | Draft subject.                                    |
| `html`        | `string`                                          | No       | None                  | HTML body.                                        |
| `text`        | `string`                                          | No       | Derived from `html`   | Plain-text body.                                  |
| `cc`          | `Recipient \| Recipient[]`                        | No       | None                  | Carbon-copy recipients.                           |
| `bcc`         | `Recipient \| Recipient[]`                        | No       | None                  | Blind-copy recipients.                            |
| `from`        | `Recipient`                                       | No       | Gmail account address | Sender address or configured Gmail send-as alias. |
| `replyTo`     | `Recipient \| Recipient[]`                        | No       | None                  | Addresses that should receive replies.            |
| `attachments` | `Attachment[]`                                    | No       | `[]`                  | Files and inline MIME parts.                      |
| `headers`     | `Record<string, string>`                          | No       | None                  | Additional RFC 5322 headers.                      |
| `priority`    | `"high" \| "normal" \| "low"`                     | No       | Not set               | Importance encoded in standard message headers.   |
| `account`     | `string \| IntegrationAccountReference<"google">` | No       | Project default       | Connected Google account that owns the draft.     |

`Recipient` is an email string or `{ address: string; name?: string }`.
`Attachment` is a `File` or an object containing `file` with optional
`filename`, `contentId`, and `disposition: "attachment" | "inline"`.

Every input, including `account`, also accepts a compatible `Signal`.

## Output

Returns a `Signal<DraftIdentifier>` with:

| Property    | Type                  | Description                                                               |
| ----------- | --------------------- | ------------------------------------------------------------------------- |
| `draftId`   | `string`              | Immutable Gmail draft ID. Use this with draft actions.                    |
| `messageId` | `string`              | Immutable ID of the message stored inside the draft.                      |
| `threadId`  | `string`              | Immutable Gmail thread ID containing the draft.                           |
| `historyId` | `string \| undefined` | Latest mailbox history record affecting the draft message, when supplied. |
| `labelIds`  | `string[]`            | Labels applied to the draft message.                                      |

`draftId` and `messageId` are different identifiers. Pass `draftId` to
`getDraft`, `updateDraft`, `sendDraft`, or `deleteDraft`.
