Errors

Every failure returns the same envelope:

{
  "error": {
    "type": "invalid_request",
    "code": "validation_failed",
    "message": "address: must match format \"email\"",
    "param": "address",
    "request_id": "req_...",
    "details": [{ "path": "/address", "rule": "format" }]
  }
}

code is the stable identifier. message is for humans and may change. request_id is what support needs.

Codes

Status Code Retry
400 validation_failed No. Inspect details[].path.
401 authentication_failed No. Send a valid bearer token.
403 permission_denied No. Add the scope or use another key.
404 not_found No. Check the id.
409 address_taken No. Choose another address.
409 domain_not_verified No. Publish the DNS records, then verify.
409 idempotency_conflict No. The same idempotency key was used with a different body.
409 conflict No. The resource is in the wrong state.
412 precondition_failed No. Re-read the resource before retrying.
429 rate_limited Yes, after the window.
429 quota_exceeded No. Upgrade or wait for the reset.
429 monthly_limit No. Resets on the billing anniversary.
429 daily_limit Yes, after 00:00 UTC.
500 internal_error Yes, with backoff.

Rate limits

Responses carry the current state:

RateLimit-Limit: 10000
RateLimit-Remaining: 9731
RateLimit-Reset: 1764547200

Retry-After is present on 429 and 503. A daily_limit response states the UTC reset.

Retrying

Retry 500, 503, and rate_limited, with exponential backoff and jitter. Do not retry validation_failed or permission_denied without changing the request; the result will be the same.

For writes, send an idempotency key so a network failure cannot create a duplicate message:

curl -X POST "$AMB_API/v1/messages/<message_id>/reply" \
  -H "Authorization: Bearer $AMB_KEY" \
  -H "Idempotency-Key: 8f2c9a1b..." \
  -H "Content-Type: application/json" \
  -d '{"text":"Thanks for flagging it."}'

The same key with the same body returns the original response. The same key with a different body returns 409 idempotency_conflict.