Messages API
Send, list, retrieve, reply to, and search messages.
Send message
curl -X POST https://getmail.bot/v1/inboxes/inbox_id/messages \
-H "Authorization: Bearer mb_xxx" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: send-welcome-4821" \
-d '{"to":["customer@example.com"],"subject":"Hello","body_text":"Hi"}'
await client.messages.send({
inboxId: 'inbox_id',
to: ['customer@example.com'],
subject: 'Hello',
bodyText: 'Hi',
});
client.messages.send(
inbox_id="inbox_id",
to=["customer@example.com"],
subject="Hello",
body_text="Hi",
)
Idempotency
A send or reply made with an API key or through MCP needs an Idempotency-Key
header of 8 to 255 characters. Choose it once per logical send. Reuse it only to
repeat the exact same request when no answer came back. After a 5xx the key is
locked: read the message back, and use a new key only if it did not go out.
The same key with the same payload returns the original response, with nothing
marking it as a repeat, so compare the message_id; the
same key with a different payload returns 409 IDEMPOTENCY_CONFLICT. A missing
or malformed key returns 400 IDEMPOTENCY_KEY_REQUIRED. 409 IDEMPOTENCY_IN_PROGRESS means the first attempt has not finished, and 409 IDEMPOTENCY_OUTCOME_UNKNOWN means it may have taken effect, so read the message
back instead of resending. Keys are kept for 24 hours. The curl examples show
the header; the Node and Python SDK helpers on this page do not set it for you.
Dashboard browser sessions are exempt.
The same header is required on the other creating calls: inboxes, domains,
webhooks, API keys, key rotation, import connections and jobs, event and
delivery replay, POST /v1/agent/provision, and the Cloudflare connect and
webhook test calls.
What a send can return
An immediate send either hands the message to the transport or stops at a check
that refuses it. A request with a future send_at can instead create a scheduled
message. Scheduled work is rechecked before delivery and may fail later. A
nonempty attachment array is denied before either path creates a message.
{
"error": {
"code": "recipient_unproven",
"message": "Delivery is not authorized."
}
}
Branch on error.code. Send Authorization
lists the checks in the order they run, and Errors is the full
reference.
Attachments
Omit attachments or send []. Any nonempty array on inbox send, global send or
reply is refused with 403, before message/thread creation, debit,
reservation, scheduled enqueue or transport:
{"error":{"code":"OUTBOUND_POLICY_DENIED","message":"Outbound attachments require an approved scanning workflow and are currently unavailable.","reason":"attachment_review_required"}}
No attachment type is accepted, including text and PDF. Malformed elements,
invalid base64 and oversized attachments in a nonempty array receive the same
policy denial. A non-array value remains 400 VALIDATION_ERROR; authentication,
abuse and the HTTP body ceiling can reject earlier, including 413 for an
oversized request body. Scheduled sends use the same early denial. Retrying the
same attachment cannot make it send. Send body_text and body_html and link to
files you host. No scanner or upload/quarantine workflow is advertised.
Inbound attachments are unaffected. They are received, stored and readable
through GET /v1/inboxes/:inboxId/messages/:messageId/attachments.
There is no built-in forward-message endpoint in this release. Read the message and create a new send if needed; the same outbound attachment denial applies.