API reference

Errors and limits

One error shape, stable codes, and the limits of every request.

Errors have one shape. code is stable (build on it); message is a sentence for a person and may be reworded; param names the field at fault. A mistake in the request is a 400; a valid request your account cannot carry out yet is a 422.

Error
{
  "error": {
    "type": "invalid_request_error",
    "code": "domain_not_verified",
    "message": "The domain acme.com is not verified yet.",
    "param": "from",
    "request_id": "req_3f9a1c2b7d4e8a0f6b5c9d1e"
  }
}

Error codes

Error codes by HTTP status
StatusCodesWhen
400invalid_jsonjson_too_deepjson_too_complexunknown_parameterrepeated_parametertoo_many_parametersquery_too_longThe body or query string cannot be read: not JSON, nested too deep or too many values, a field or parameter we do not know, or one given twice.
400requiredinvalid_typeinvalid_valueinvalid_formatinvalid_characterstoo_longtoo_few_itemstoo_many_itemsout_of_rangeinvalid_keyA field has the wrong type, is missing or empty, is too long or too short, is not one of the allowed values, or holds a character that cannot be stored (NUL, a broken Unicode surrogate). param names the field.
400invalid_frominvalid_subjectmissing_recipienttoo_many_recipientsmissing_bodyinvalid_headerinvalid_taginvalid_scheduleinvalid_attachmentattachments_too_largeattachments_not_supportedThe email itself is not valid: see the message, which says what to change.
400invalid_cursorinvalid_idempotency_keyA cursor from another list or filter, or an Idempotency-Key that is not 1 to 255 visible ASCII characters.
400conflicting_bodyvariables_without_templatetoo_many_templatestoo_many_variablesvariables_too_deepvariables_too_largeinvalid_variableTemplates: both template_id and html / text, variables without a template_id, too many different templates in one batch, or variables over a limit.
401invalid_api_keyNo key, or a key that is unknown, revoked or of a suspended account (one answer for all of them).
403browser_request_refusedThe request came from a web page (it had an Origin header). Call the API from your server.
403insufficient_scopeThe key lacks the permission. Create a key with it under API keys.
403sandbox_recipientaccount_inactiveIn the sandbox, a recipient who is not on your team; or the account cannot send.
403payment_method_requiredCampaigns: add a payment method before sending marketing email.
404not_foundNo such email (or one of another account), or no such endpoint.
405method_not_allowedThe path does not take this method. The Allow header lists the ones it does.
409not_schedulednot_cancellableThe email has started sending (or was sent, failed or cancelled), so it can no longer be rescheduled or cancelled.
409idempotency_key_reusedidempotency_in_progressThe Idempotency-Key was used for a different request, or the first request with it is still running (retry after Retry-After).
409campaign_not_draftcampaign_not_cancellableCampaigns: it was already sent or scheduled (a campaign is sent once), or there is nothing to cancel.
413body_too_largeThe request body is over the limit of the endpoint.
422domain_not_founddomain_not_verifiedThe request is valid, but the From domain is not one of your sending domains, or is not verified yet.
422template_not_foundtemplate_not_transactionaltemplate_unusabletemplate_render_failedmissing_subjectTemplates: no template of yours has this id; it is a marketing template (use a transactional one); its HTML cannot be sent (fix it in the app); filled in with these variables it would be too large; or it has no subject and the request gives none.
422sender_not_foundaudience_not_foundtopic_not_foundinvalid_htmlunsupported_htmlmailing_address_missingno_recipientsCampaigns: the sender, a list or segment, or the topic is not one of yours; the HTML cannot be sent as it is (the message lists what to change); the account has no postal address; or nobody in the audience can be emailed (the message says why).
429rate_limitedsandbox_daily_limitToo many requests for this key this minute (wait Retry-After), or the sandbox's daily emails are used.
500 / 503internal_errorattachments_unavailableSomething failed on our side. Retry with the same Idempotency-Key.

An email that was accepted but could not be sent has status: "failed" and a plain-language error. This is rare: a message SES rejects for its content, or a send interrupted midway (never retried, so nobody gets it twice). An error's type is one of invalid_request_error, authentication_error, permission_error, rate_limit_error, idempotency_error and api_error.

Limits

  • A request body up to 15 MiB (6 MiB for a batch); JSON nested at most 12 levels and at most 60,000 values.
  • HTML and text up to 1,048,576 characters each; a subject up to 998 characters, on one line, without control characters. Lengths are counted in UTF-16 code units, as JavaScript's .length does: most emoji count as 2.
  • Up to 15 custom headers; a header's name (up to 76 characters) and value together at most 996 characters. An X-… value may use any language; List-Unsubscribe, List-Id, In-Reply-To, References and the like must be plain ASCII.
  • 10 tags; reply_to up to 10 addresses; an Idempotency-Key of 1 to 255 visible ASCII characters; a query string up to 2,048 characters.
  • Recipients are plain addresses (no names), lower-cased, with repeats dropped. The From name may not contain an email address or quotes. An optional field may be left out or given as null.
  • Dates are ISO 8601 with an offset; in a query string, write the + of an offset as %2B (or use Z).
  • Your account has a rolling 24-hour sending limit that grows as your sending stays healthy; an email over it waits in the queue rather than failing.