sendsend.email

Errors

Every error has the same shape, so one handler covers them all.

{
  "statusCode": 422,
  "name": "domain_not_verified",
  "message": "Sending domain \"mail.acme.com\" is not verified for this project",
  "error": {
    "code": "domain_not_verified",
    "message": "Sending domain \"mail.acme.com\" is not verified for this project",
    "request_id": "req_Kd83...",
    "details": {}
  }
}

Switch on error.code, not message. Quote the request_id if you contact support. statusCode, name and message repeat the essentials at the top level for clients that look there. name is the same as code except for a few that use more familiar names: invalid_api_key (401), restricted_api_key (403), rate_limit_exceeded (429), monthly_quota_exceeded and daily_quota_exceeded.

StatusCodeMeaning
400validation_errorThe request is invalid. The message names the field.
400invalid_variablesA template variable is missing or has the wrong type.
401unauthorizedMissing, invalid or revoked API key.
403forbiddenThe key lacks the needed scope.
403account_not_approvedLive sending is waiting for account approval.
403account_suspendedThe account is paused.
403plan_limit_reachedYour plan’s limit (domains, webhooks, projects…) is reached. Upgrade to add more.
404not_foundNo such resource in this project.
409not_schedulableYou tried to reschedule or cancel an email that is not waiting for its time any more.
409idempotency_conflictThe key was used with a different body.
409domain_already_registeredAnother project already registered this domain.
413payload_too_largeThe request is over 2 MiB.
422domain_not_verifiedThe From domain is not verified in this project.
422recipient_suppressedEvery recipient is suppressed.
429rate_limitedToo many requests. Wait the number of seconds in Retry-After.
429daily_limit_exceededThe project reached its daily limit.
429quota_exhaustedThe monthly allowance or spend cap is used up.

What to retry

  • Retry network errors, timeouts and 5xx responses, with the same Idempotency-Key, and 429 after waiting.
  • Do not retry 4xx errors other than 429. Fix the request first.