Skip to content
Menu

Reference

API errors

Markdown version

The error envelope every API endpoint shares, what each HTTP status means, when to retry, the rate-limit headers and idempotency conflicts.

Before you start

The error envelope

Every JSON endpoint answers a failure with one field:

json
{ "error": "Invalid API key" }

The message is a short sentence you can log or show to an operator. A server failure reads Internal server error, and the details stay in Herald's logs. Success is always { "data": ... }. A validation message names the field, such as recipients[0].external_user_id must be 1 to 255 characters or Invalid events payload: ....

Two endpoints answer differently: the decisions CSV returns text/csv on success (its errors are still JSON), and the MCP server answers with JSON-RPC errors inside a 200 once the key is accepted.

HTTP status codes

StatusMeaningRetry?What to do
200Done. For events, check rejectedFix and resend any rejected events
202Accepted: a send was scheduledKeep send_id
400The request breaks a rule; the message says whichNoFix the request
401Missing, unknown, revoked or expired credentialNoCheck the key or token
403The credential is valid but not allowed: a missing scope, a disabled app, an IP outside the key's allowlist, or the wrong kind of connectionNoFix the key's scopes or the app's settings
404The resource doesn't exist in this appNoCheck the ID
409A conflict: the send already started, the agent isn't active, or an idempotency key clashNo, except "still in progress"See Idempotency conflicts
413The body is too large, such as Body exceeds 4 MB or Request body too large (over 4.5 MB on any endpoint)NoSplit the request
429Over an hourly rate limitYes, after Retry-AfterWait, or spread the load
500Server failure, Internal server errorYes, with backoffContact your account team if it persists
502, 503, 504Gateway or upstream failureYes, with backoffNone needed if it clears

Retry with exponential backoff and jitter, and cap the wait. Never retry a 4xx other than 409 "still in progress" and 429.

Rate limits

Requests made with an API key are counted in hourly pools per app, per UTC clock hour. The Send API lists them; the MCP server counts toward mcp.requests (3,600 per hour) and the decisions CSV toward exports.requests (60 per hour).

Every response to a request with a valid API key carries the headers of the tightest pool it charged:

HeaderValue
X-RateLimit-PoolThe pool, such as messages.push
X-RateLimit-LimitIts limit per hour
X-RateLimit-RemainingWhat is left this hour
X-RateLimit-ResetWhen the hour ends, in Unix epoch seconds
Retry-AfterOn a 429 only: seconds until the hour ends

A 429 body names the pool: Rate limit exceeded for messages.sms: 2000 per hour. Nothing in the request was charged or done, so you can retry the same request after Retry-After. A 401, and the 403s for a disabled app or a blocked IP, come before any charge and carry no rate-limit headers.

Note

Beta: the SDK, web push subscribe and server ingest endpoints (POST /api/v1/events, POST /api/v1/users) also get hourly pools per app, answering 429 with Retry-After and the same headers. The SDKs honor it. This is not live in production yet.

Idempotency conflicts

POST /api/v1/messages/send takes an Idempotency-Key. See Send API idempotency.

StatusBody errorWhat to do
409This Idempotency-Key was used with a different requestUse a new key for a new request; reuse a key only for an exact retry
409A request with this Idempotency-Key is still in progressWait a few seconds and retry with the same key. A claim unfinished after 2 minutes is taken over

A replay of a finished request returns the first response with its original status, not an error. The server API endpoints take no key; their writes are keyed instead (see Server API idempotency).

Rejected events

POST /api/v1/events checks each event on its own. A bad event doesn't fail the request: it is left out and listed in rejected with a reason code, and the rest are stored with a 200. Retrying a rejected event never helps; fix it first. The codes are listed under Rejected events.

Common messages

StatusBody errorWhereCause
400Invalid JSON or Invalid JSON bodyAllThe body is not JSON
401UnauthorizedServer APIMissing or unknown ingest token
401Invalid API keySend API, decisions CSV, MCPMissing, unknown, revoked or expired API key
403ForbiddenServer APIThe connection is disabled
403This API key lacks the <scope> scopeSend API, decisions CSV, MCPWrong scopes
403This API key's app is disabledSend API, decisions CSV, MCPThe app is turned off
403This IP address isn't allowed for this API keySend API, decisions CSV, MCPThe key has an IP allowlist
413Request body too largeAllOver the endpoint's body limit
429Rate limit exceeded for <pool>: <limit> per hourAPI key endpointsOver a pool's hourly limit
500Internal server errorAllServer failure

Each endpoint's own messages are in its table on Server API and Send API.

See Herald decide live →