Mail API reference

Mail API · Drafts

patch/v1/workspaces/{workspace_id}/drafts/{id}Auth

Edit a draft

Changes a `draft` or `pending_approval` draft; pass the `version` you read. A submitted draft edited by its author goes back to `draft` (submit it again); edited by anyone else it stays waiting for approval. `attachments` replaces the stored files. Needs `mail.draft.create` on the mailbox.

Path parameters

workspace_id*string · uuid

Id of the workspace.

id*string · uuid

Draft id.

Headers

Idempotency-Keystring

Opaque client-generated string (1–256 chars, `[A-Za-z0-9._:-]`) used to deduplicate retries within a 24h window. A retry with the same key and body returns the original response with `Idempotent-Replay: true`.

Request body

htmlstring

HTML body. At least one of `html` and `text` before the draft is submitted or sent. Replies quote the answered message under it when sent (`quote`).

Example: "<p>Thanks, the refund is on its way.</p>"

textstring

Plain-text body. At least one of `html` and `text` before the draft is submitted or sent.

Example: "Thanks, the refund is on its way."

toobject

Recipients. Replies: replaces the computed ones (the answered message's `Reply-To`, else its sender; reply-all adds its `To` and `Cc`). Forwards and new emails: required before sending. At most 50 recipients across `to`, `cc` and `bcc`.

Example: ["success@simulator.amazonses.com"]

ccobject

Cc recipients: one address or an array. Shown in the `Cc` header to every recipient.

Example: ["finance@example.com"]

bccobject

Bcc recipients: one address or an array. Each gets the message; no header names them.

Example: ["audit@example.com"]

subjectstring

Subject. Replies default to `Re: ` + the answered subject, forwards to `Fwd: ` + it.

Example: "Re: Refund for order 42"

quoteboolean

Replies: quote the answered message under the text when sent. Default true.

attachmentsarray

Files, as on `POST /emails` (at most 20, 10 MB in total after decoding; executable types are refused). Stored with the draft and sent with it; on an edit the list replaces the stored one.

version*integer

The `version` you read. Someone else changed the draft since: 409 `MAIL_DRAFT_VERSION_CONFLICT` (`details.version` is the current one); read it again.

Example: 1

Response · 200

id*string · uuid

Draft id.

mailbox_id*string · uuid

The mailbox it is sent from.

thread_id*string · uuid

The conversation; null for a `new` email until it is sent.

reply_to_message_id*string · uuid

The message answered or forwarded; null for `new`.

kind*object

`reply`, `reply_all`, `forward` (of `reply_to_message_id`) or `new` (a new email from the mailbox).

status*object

`draft` → `pending_approval` (submitted) → `sent` (approved and sent) or `rejected`. `discarded` when deleted. `approved` only while the send is in flight.

to*array

To recipients (for replies, computed when the draft was created).

cc*array

Cc recipients.

bcc*array

Bcc recipients.

subject*string

Subject it will go out with.

text*string

Plain-text body written in the draft (the quote of the answered message is added when sent).

html*string

HTML body written in the draft.

quote*boolean

Replies: the answered message is quoted under the text when sent.

attachments*array

Files stored with the draft.

author*object
type*object

`user`: a person signed in. `api_key`: a Platform API Key. `agent`: an MCP grant or an OAuth client acting for a person.

id*string · uuid

Account id (people, and the person an agent acted for) or API key id.

label*string

Display label: the OAuth client, key name or email.

is_agent*boolean

Written by an agent (MCP grant or OAuth client).

on_behalf_of_user_id*string · uuid

The person an agent acted for, or who created the API key. They cannot approve it.

client_id*string

OAuth client id of an agent.

submitted_at*string · date-time

When it was submitted for approval.

reviewed_by*string · uuid

The person who approved or rejected it.

reviewed_at*string · date-time

When it was approved or rejected.

review_note*string

The reviewer's note.

sent_email_id*string · uuid

The email it was sent as (`GET /emails/{id}`; a message of the thread).

version*integer

Bumped on every change; pass it to edit, approve or send.

Example: 1

created_at*string · date-time

When the draft was created.

updated_at*string · date-time

When it last changed.

Example

Request

PATCH https://api.mail.productcraft.co/v1/workspaces/{workspace_id}/drafts/{id}
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json

{
  "html": "<p>Thanks, the refund is on its way.</p>",
  "text": "Thanks, the refund is on its way.",
  "to": [
    "success@simulator.amazonses.com"
  ],
  "cc": [
    "finance@example.com"
  ],
  "bcc": [
    "audit@example.com"
  ],
  "subject": "Re: Refund for order 42",
  "quote": false,
  "attachments": [
    {
      "filename": "invoice-1234.pdf",
      "content": "JVBERi0xLjcKJcfsj6IKMSAwIG9iago8PC9UeXBlL0NhdGFsb2c+PgplbmRvYmoK",
      "path": "https://files.acme.com/invoices/1234.pdf",
      "content_type": "application/pdf",
      "content_id": "logo"
    }
  ],
  "version": 1
}

Response

{
  "id": "00000000-0000-0000-0000-000000000000",
  "mailbox_id": "00000000-0000-0000-0000-000000000000",
  "thread_id": "00000000-0000-0000-0000-000000000000",
  "reply_to_message_id": "00000000-0000-0000-0000-000000000000",
  "kind": {},
  "status": {},
  "to": [
    "string"
  ],
  "cc": [
    "string"
  ],
  "bcc": [
    "string"
  ],
  "subject": "string",
  "text": "string",
  "html": "string",
  "quote": false,
  "attachments": [
    {
      "filename": "invoice-1234.pdf",
      "content_type": "application/pdf",
      "size": 18232
    }
  ],
  "author": {
    "type": {},
    "id": "00000000-0000-0000-0000-000000000000",
    "label": "string",
    "is_agent": false,
    "on_behalf_of_user_id": "00000000-0000-0000-0000-000000000000",
    "client_id": "string"
  },
  "submitted_at": "2026-01-01T00:00:00.000Z",
  "reviewed_by": "00000000-0000-0000-0000-000000000000",
  "reviewed_at": "2026-01-01T00:00:00.000Z",
  "review_note": "string",
  "sent_email_id": "00000000-0000-0000-0000-000000000000",
  "version": 1,
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z"
}