Skip to content

REST API

The REST API allows you to send emails from any application using a standard HTTP request to POST /accounts/{account_id}/email/sending/send. Use it from any backend, serverless function, or CI/CD pipeline — no Cloudflare Workers binding is required.

For the full OpenAPI specification, refer to the Email Sending API reference.

Cloudflare also provides official SDKs for the REST API: Node, Python, and Go.

Authentication

Authenticate with a Cloudflare API token that has permission to send emails. Include it in the Authorization header:

Authorization: Bearer <API_TOKEN>

Send an email

Terminal window
curl "https://tdx-api-cloudflare-com.pipotar.top/client/v4/accounts/{account_id}/email/sending/send" \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data '{
"to": "recipient@example.com",
"from": "welcome@yourdomain.com",
"subject": "Welcome to our service!",
"html": "<h1>Welcome!</h1><p>Thanks for signing up.</p>",
"text": "Welcome! Thanks for signing up."
}'

For multiple recipients, CC/BCC, and named addresses, see Specify recipients.

Attachments

Send files by including base64-encoded content in the attachments array. The total message size must not exceed 5 MiB (including attachments).

Terminal window
curl "https://tdx-api-cloudflare-com.pipotar.top/client/v4/accounts/{account_id}/email/sending/send" \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data '{
"to": "customer@example.com",
"from": "invoices@yourdomain.com",
"subject": "Your Invoice",
"html": "<h1>Invoice attached</h1><p>Please find your invoice attached.</p>",
"attachments": [
{
"content": "JVBERi0xLjQKJeLjz9MK...",
"filename": "invoice-12345.pdf",
"type": "application/pdf",
"disposition": "attachment"
}
]
}'

For inline images and file uploads, see Email attachments.

Custom headers

Set custom headers for threading, list management, or tracking. Refer to the email headers reference for the full list of allowed headers.

Terminal window
curl "https://tdx-api-cloudflare-com.pipotar.top/client/v4/accounts/{account_id}/email/sending/send" \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data '{
"to": "user@example.com",
"from": "notifications@yourdomain.com",
"subject": "Your weekly digest",
"html": "<h1>Weekly Digest</h1>",
"headers": {
"List-Unsubscribe": "<https://tdx-yourdomain-com.pipotar.top/unsubscribe?id=abc123>",
"List-Unsubscribe-Post": "List-Unsubscribe=One-Click",
"X-Campaign-ID": "weekly-digest-2026-03"
}
}'

Response

A successful response returns the delivery status for each recipient:

{
"success": true,
"errors": [],
"messages": [],
"result": {
"delivered": ["recipient@example.com"],
"permanent_bounces": [],
"queued": []
}
}
  • delivered - Email addresses to which the message was delivered immediately
  • permanent_bounces - Email addresses that permanently bounced
  • queued - Email addresses for which delivery was queued for later

Error handling

The REST API returns standard Cloudflare API error responses. A failed request returns an errors array with numeric error codes and machine-readable messages:

{
"success": false,
"errors": [
{
"code": 10001,
"message": "email.sending.error.invalid_request_schema"
}
],
"messages": [],
"result": null
}

REST API error codes:

HTTP StatusCodeMessageDescription
40010001email.sending.error.invalid_request_schemaInvalid request format
40010200email.sending.error.email.too_bigEmail exceeds size limit
40010201email.sending.error.email.no_content_lengthMissing content length
40010202email.sending.error.email.invalidInvalid email content
40110101email.sending.error.authentication.unauthorizedMissing or invalid API token
40110103email.sending.error.authentication.bad_token_typeWrong token type for this endpoint
40310102email.sending.error.authentication.forbiddenToken lacks permission to send
40310105email.sending.error.authentication.not_entitledAccount not entitled to use Email Sending
40310203email.sending.error.email.sending_disabledSending disabled for this zone or account
40410000email.sending.error.not_foundResource not found
42910004email.sending.error.throttledRate limit exceeded
50010002email.sending.error.internal_serverInternal server error
50010003email.sending.error.not_implementedOperation not implemented
50310100email.sending.error.authentication.upstreamAuthentication service temporarily unavailable

Next steps

  • Refer to the Email Sending API reference for the full request and response schemas.
  • See the Workers API for sending emails directly from Cloudflare Workers using bindings.
  • See SMTP for sending from any SMTP-capable application or mail client.
  • Review email headers for threading, list management, and custom tracking headers.