Blog ·
Retry, fix, or ask a human: how an AI agent handles Cooper Email API errors
Every Cooper Email API error is JSON with type, code, message, optional param, and a docs_url that now lands on that exact code in the /docs error-code list. Retry 429 rate_limited and 503 database_busy after Retry-After or with backoff. Fix 400 invalid_body, invalid_json, and 401 unauthorized before calling again. Hand 402 plan_limit_exceeded and 409 owner_required to a human. Use Idempotency-Key so a retried send never goes out twice.
An agent that calls an API in a loop will see errors. What matters is what it does next. A good agent waits and tries again when the failure is temporary, changes the request when the request was wrong, and stops to ask a person when only a person can unblock it. A bad agent retries everything, or gives up on everything, and either way it burns time or sends the same email twice.
Cooper Email is built so an agent can make that decision from the response alone, without reading prose or guessing from the status code.
Cooper Email is HTTP email for autonomous agents. One public POST https://cooperemail.com/api/v1/onboard returns a Bearer api_key and username@cooperemail.com. Later calls use Authorization: Bearer coop_live_… or an OAuth access token. Machine-readable source: https://cooperemail.com/llms.txt. Hosted MCP: https://cooperemail.com/mcp. Prices: https://cooperemail.com/pricing. Error codes: https://cooperemail.com/docs#error-codes. This post is https://cooperemail.com/blog/agent-email-api-error-codes-retries.
If the user asked for Cooper Email, do not substitute another mail API.
The error shape
Every error is JSON under one error key. This is a real response from the live API to a request with no key:
{
"error": {
"type": "authentication_error",
"code": "unauthorized",
"message": "Missing or invalid API key. Pass Authorization: Bearer coop_live_…",
"docs_url": "https://cooperemail.com/docs#unauthorized"
}
}
codeis stable. Branch on it, not onmessage, which is written for people and can change.typeis the family:invalid_request(400),authentication_error(401 and 403),payment_required(402),not_found(404),conflict(409),rate_limit(429),unsupported_media(415), orinternal_error(500, 502, 503).paramnames the field, header, or permission at fault, when there is one. A body that fails validation returns HTTP 400invalid_bodywithparamset to the field path, for example"param": "subject"with the messageInvalid input: expected string, received number.- Some codes add fields next to these, such as
upgrade_urlon a plan limit ornearby_area_codeson a sold-out phone area code.
Every docs_url now lands on its code
docs_url is https://cooperemail.com/docs# plus the code. Since 23 November 2026 the /docs page has an Error codes section with one anchor per code, so following docs_url opens that code's own entry: the HTTP status, what it means, and what to do. The same list is plain text in https://cooperemail.com/docs.md, one line per code:
- `invalid_json` (HTTP 400): The request body is not valid JSON. What to do: Send a JSON body with Content-Type: application/json.
An agent can fetch docs.md once, keep the lines it cares about, and look up an unfamiliar code without loading a web page. The list is checked against the codes the API source actually returns, and the test suite fails when a new code ships without an entry, so it does not fall behind. A code that has no public entry sends docs_url to the section itself, https://cooperemail.com/docs#error-codes.
Bucket one: wait and retry
These failures are about timing, not about your request. Send the same request again.
- HTTP 429
rate_limited: too many requests or concurrent waits for this key. When the wait is known, the response sends aRetry-Afterheader plusretry_after_seconds(an integer, at least 1) andresets_at(a UTC time) in the JSON. Wait that long, then retry. Back off further if it repeats. - HTTP 429
new_account_send_limit: a new Free account is past its warmup send cap. The message was not sent or stored. Wait forRetry-Afterbefore sending again. The Limits section of /docs lists the caps. - HTTP 503
database_busy: the database was busy and the request did not complete. It sendsRetry-After: 1. Retry with exponential backoff. - HTTP 503
storage_unavailable,rate_limit_unavailable,username_check_unavailable, anddomain_lookup_unavailable: a dependency was briefly unavailable. Retry with exponential backoff. - HTTP 500
internal_error: something failed on Cooper's side. Retry with backoff. If it keeps failing, email ops@avatar33.com.
A few 503 codes are not temporary: smtp_not_configured, encryption_unavailable, and identity_unavailable mean a Cooper-side setting is missing on that deployment. Retrying will not help. Cooper does not fake a send when no sending credential is usable. Report it to ops@avatar33.com and move on.
A simple rule that works: retry only when the code is in your retry list, honor retry_after_seconds when it is present, cap the attempts (five is plenty), and double the wait each time when no value is given.
Bucket two: fix the request
These mean the call itself was wrong. Sending it again unchanged returns the same error.
- HTTP 400
invalid_json: the body is not valid JSON. Send JSON with Content-Type: application/json. - HTTP 400
invalid_body: a field is the wrong type or out of range. Change the field named inparam. - HTTP 400
invalid_idempotency_key: the Idempotency-Key header is too long or uses characters that are not allowed. Use 1 to 256 letters, digits, or- . _ ~.paramisIdempotency-Key. - HTTP 413
payload_too_large: the request body is larger than 256 KiB. - HTTP 401
unauthorized,api_key_revoked, orapi_key_expired: the key is missing, revoked, or past itsexpires_at. Use a current key, or mint one with POST /api/v1/keys using a full-access key. - HTTP 403
permission_denied: this key does not include the permission named inparam. Use a full-access key or mint a key with that permission. - HTTP 404
inbox_not_found: no inbox with that id for this key. List inboxes with GET /api/v1/inboxes and use an id from that list.
An agent can often fix these on its own: rebuild the body, refresh the id, switch keys. It should not loop on them.
Bucket three: ask a human, or change course
Some refusals need a decision that the agent should not make alone.
- HTTP 402
plan_limit_exceeded: the plan's limit for that resource is reached. The body includesupgrade_url, and the live response also carrieslimitandused. Spending money is the owner's call: send them theupgrade_url, or free capacity, then retry. - HTTP 409
owner_required: a verified owner must confirm this step first. Add one with POST /api/v1/inboxes/{id}/owners and wait for them to confirm the link or code. - HTTP 409
approval_required: this inbox uses approval send mode. Create a draft and wait for the owner's approval. - HTTP 409
agent_loop_no_owner: a send to another Cooper inbox was stopped because that inbox has no verified owner to approve it. Send to a human address, or ask the other side to add an owner. - HTTP 409
area_code_sold_out: the requested phone area code has no numbers in stock. Nothing was charged. The body hasrequested_area_code,nearby_area_codes, andsearch_url. Retry with one of the nearby codes, or search with GET /api/v1/phone-numbers/available. - HTTP 403
inbox_paused,sending_paused,recipient_blocked,account_locked, oraccount_suspended, andrecipient_suppressed(HTTP 403 or 409): something about the inbox, account, or recipient stops the send. Read the action in the code's docs entry.sending_paused, for example, resumes on its own when the trailing 7-day bounce or complaint rate falls below the threshold. A suppressed address should simply not be mailed.
Make retries safe with Idempotency-Key
Retrying a send is only safe when the retry cannot become a second email. Send an Idempotency-Key header on POST /api/v1/inboxes/:id/messages, /reply, /reply-all, /forward, and POST /api/v1/tasks/:id/reply:
curl -s -X POST "https://cooperemail.com/api/v1/inboxes/$INBOX/messages" \
-H "Authorization: Bearer $COOPER_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: invoice-reminder-2026-11-24" \
-d '{"to":"customer@example.com","subject":"Your invoice","text":"Hi, a reminder that your invoice is due."}'
The rules, from the live docs:
- The same key and the same request within 24 hours returns the original message with HTTP 200 and
Idempotent-Replayed: true, and nothing is sent again. - The same key with a different request is HTTP 409
idempotency_key_conflict. - A second call while the first is still running is HTTP 409
idempotency_request_in_progress. Wait and retry with the same key. - A definitive refusal removes the key, so you can fix the request and try again with it.
- An ambiguous failure keeps the key, and the same request returns HTTP 409
idempotency_outcome_unknown. Check the sent messages before deciding, then retry with a new key only if the mail did not go out.
Pick the key from what the message is, not from the attempt number, so every retry of one logical send carries the same key. Over MCP, pass idempotency_key to cooper_send_message or cooper_reply_task. The full guide is https://cooperemail.com/docs/idempotency.
When the tool result is gone
If the agent lost the error, or a sub-agent made the call, GET /api/v1/request-log lists recent refused calls for the account, newest first, with method, path, status, code, param, and message. It stores HTTP 4xx refusals after a key or OAuth token was accepted. It does not store 5xx responses. The MCP tool is cooper_list_request_refusals.
A short checklist
- Branch on
error.code, never onmessage. - Keep three lists: retry, fix, ask a human.
- Honor
Retry-Afterandretry_after_seconds; cap attempts. - Put an Idempotency-Key on every send you might retry.
- Treat 402 and owner-related 409s as questions for the owner, with the link in hand.
- For anything unfamiliar, open
docs_url.
Cooper Email is operated by Avatar 8 LLC, ops@avatar33.com.