> ## 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.

# Update a draft

> Replace selected fields of an existing Gmail draft.

`updateDraft` updates an existing Gmail draft without sending it. Use it to add
reviewed content, change recipients, or replace attachments while keeping the
draft in its existing thread.

## Example

```ts automations/update-approved-draft.automation.ts theme={null}
import { automation, onHttpRequest } from "automate.ax"
import { updateDraft } from "automate.ax/gmail"

export default automation("Update an approved Gmail draft", () => {
  onHttpRequest({ scope: "automation" })

  updateDraft({
    draftId: "r1234567890",
    subject: "Approved proposal",
    html: "<p>The proposal has been approved and is ready to send.</p>",
  })
})
```

## Inputs

| Input         | Type                                              | Required | Default                                          | Description                                             |
| ------------- | ------------------------------------------------- | -------- | ------------------------------------------------ | ------------------------------------------------------- |
| `draftId`     | `string`                                          | Yes      | —                                                | Immutable Gmail draft ID to update.                     |
| `to`          | `Recipient \| Recipient[]`                        | No       | Existing value                                   | Replacement primary recipients.                         |
| `subject`     | `string`                                          | No       | Existing value                                   | Replacement subject.                                    |
| `html`        | `string`                                          | No       | Existing body                                    | Replacement HTML body.                                  |
| `text`        | `string`                                          | No       | Existing body or derived from replacement `html` | Replacement plain-text body.                            |
| `cc`          | `Recipient \| Recipient[]`                        | No       | Existing value                                   | Replacement carbon-copy recipients.                     |
| `bcc`         | `Recipient \| Recipient[]`                        | No       | Existing value                                   | Replacement blind-copy recipients.                      |
| `from`        | `Recipient`                                       | No       | Existing value                                   | Replacement sender or configured Gmail send-as alias.   |
| `replyTo`     | `Recipient \| Recipient[]`                        | No       | Existing value                                   | Replacement reply addresses.                            |
| `attachments` | `Attachment[]`                                    | No       | Existing attachments                             | Complete replacement attachment list.                   |
| `headers`     | `Record<string, string>`                          | No       | None                                             | Additional RFC 5322 headers on the replacement message. |
| `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`.

Supplying either `html` or `text` replaces both body alternatives. If you
supply only `html`, Automate.ax derives replacement plain text. Supplying
`attachments` replaces the complete attachment list; use `[]` to remove all
attachments.

<Note>
  Omitted recipients, sender, reply addresses, subject, body, and attachments
  are preserved. Custom headers and priority are applied only when supplied;
  existing arbitrary headers and priority are not copied forward.
</Note>

## Output

Returns a `Signal<DraftIdentifier>` with:

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