curl --request POST \
--url https://{dsn}/api/v1/emails \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"account_id": "acc_ba1fa6938d8548298e8ce62e4b4b4e99",
"to": [
{
"display_name": "Ana Lee",
"identifier": "ana@example.com"
}
],
"subject": "Meeting tomorrow",
"body": "<p>Hi Ana,</p><p>Are we still on for 10:00?</p>"
}
'{
"object": "EmailSent",
"account_id": "acc_ba1fa6938d8548298e8ce62e4b4b4e99",
"message_id": "84c3db9476d84b288bc6fa055a576764@mail-api.example.com",
"provider_id": "1a1108eec86709d8",
"tracking_id": null
}{
"status": 400,
"type": "errors/invalid_parameters",
"title": "Invalid parameters",
"detail": "limit must be between 1 and 250"
}{
"status": 401,
"type": "errors/invalid_credentials",
"title": "Invalid credentials",
"detail": "the mail provider rejected the credentials: invalid_grant"
}{
"status": 404,
"type": "errors/not_found",
"title": "Not found",
"detail": "email email_94a0d77db739407e932c3b97fef44aac not found"
}{
"status": 422,
"type": "errors/provider_rejected",
"title": "Rejected by the provider",
"detail": "Message too large"
}{
"status": 502,
"type": "errors/provider_error",
"title": "Mail provider error",
"detail": "timed out talking to imap.example.com"
}Send an email
Sends an email from the account’s own address, through the provider’s SMTP server.
It appears in the user’s Sent folder (an email.new event follows, with
origin: "api").
Reply: set reply_to to the email_… id you answer. The engine fills in the
recipients, the subject (Re: …) and the threading headers.
Attachments: multipart/form-data with files in fields named attachments, or JSON
with base64 content. Up to 30 MB per request.
Tracking: tracking_options reports opens and clicks (tracking.open,
tracking.click).
At least one recipient is needed, unless you use reply_to.
curl --request POST \
--url https://{dsn}/api/v1/emails \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--data '
{
"account_id": "acc_ba1fa6938d8548298e8ce62e4b4b4e99",
"to": [
{
"display_name": "Ana Lee",
"identifier": "ana@example.com"
}
],
"subject": "Meeting tomorrow",
"body": "<p>Hi Ana,</p><p>Are we still on for 10:00?</p>"
}
'{
"object": "EmailSent",
"account_id": "acc_ba1fa6938d8548298e8ce62e4b4b4e99",
"message_id": "84c3db9476d84b288bc6fa055a576764@mail-api.example.com",
"provider_id": "1a1108eec86709d8",
"tracking_id": null
}{
"status": 400,
"type": "errors/invalid_parameters",
"title": "Invalid parameters",
"detail": "limit must be between 1 and 250"
}{
"status": 401,
"type": "errors/invalid_credentials",
"title": "Invalid credentials",
"detail": "the mail provider rejected the credentials: invalid_grant"
}{
"status": 404,
"type": "errors/not_found",
"title": "Not found",
"detail": "email email_94a0d77db739407e932c3b97fef44aac not found"
}{
"status": 422,
"type": "errors/provider_rejected",
"title": "Rejected by the provider",
"detail": "Message too large"
}{
"status": 502,
"type": "errors/provider_error",
"title": "Mail provider error",
"detail": "timed out talking to imap.example.com"
}Authorizations
Your access token, from your dashboard under API keys.
Body
The account to send from (acc_…).
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Sender name; identifier can set a send-as alias.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
HTML body.
The email_… id you answer.
X-…, List-Unsubscribe, List-Unsubscribe-Post or Reply-To.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Response
The email is sent.
"EmailSent"The Message-ID of the sent email. Its Sent copy has the same message_id.
Always null: SMTP returns no id when sending. The Sent copy gets its ids when it syncs.
Set when tracking_options is used (trk_…).