Reference
API errors
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
- You call the Server API or the Send API from your backend. The SDK handles its own errors: see Error codes.
The error envelope
Every JSON endpoint answers a failure with one field:
{ "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
| Status | Meaning | Retry? | What to do |
|---|---|---|---|
| 200 | Done. For events, check rejected | Fix and resend any rejected events | |
| 202 | Accepted: a send was scheduled | Keep send_id | |
| 400 | The request breaks a rule; the message says which | No | Fix the request |
| 401 | Missing, unknown, revoked or expired credential | No | Check the key or token |
| 403 | The credential is valid but not allowed: a missing scope, a disabled app, an IP outside the key's allowlist, or the wrong kind of connection | No | Fix the key's scopes or the app's settings |
| 404 | The resource doesn't exist in this app | No | Check the ID |
| 409 | A conflict: the send already started, the agent isn't active, or an idempotency key clash | No, except "still in progress" | See Idempotency conflicts |
| 413 | The body is too large, such as Body exceeds 4 MB or Request body too large (over 4.5 MB on any endpoint) | No | Split the request |
| 429 | Over an hourly rate limit | Yes, after Retry-After | Wait, or spread the load |
| 500 | Server failure, Internal server error | Yes, with backoff | Contact your account team if it persists |
| 502, 503, 504 | Gateway or upstream failure | Yes, with backoff | None 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:
| Header | Value |
|---|---|
X-RateLimit-Pool | The pool, such as messages.push |
X-RateLimit-Limit | Its limit per hour |
X-RateLimit-Remaining | What is left this hour |
X-RateLimit-Reset | When the hour ends, in Unix epoch seconds |
Retry-After | On 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.
| Status | Body error | What to do |
|---|---|---|
| 409 | This Idempotency-Key was used with a different request | Use a new key for a new request; reuse a key only for an exact retry |
| 409 | A request with this Idempotency-Key is still in progress | Wait 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
| Status | Body error | Where | Cause |
|---|---|---|---|
| 400 | Invalid JSON or Invalid JSON body | All | The body is not JSON |
| 401 | Unauthorized | Server API | Missing or unknown ingest token |
| 401 | Invalid API key | Send API, decisions CSV, MCP | Missing, unknown, revoked or expired API key |
| 403 | Forbidden | Server API | The connection is disabled |
| 403 | This API key lacks the <scope> scope | Send API, decisions CSV, MCP | Wrong scopes |
| 403 | This API key's app is disabled | Send API, decisions CSV, MCP | The app is turned off |
| 403 | This IP address isn't allowed for this API key | Send API, decisions CSV, MCP | The key has an IP allowlist |
| 413 | Request body too large | All | Over the endpoint's body limit |
| 429 | Rate limit exceeded for <pool>: <limit> per hour | API key endpoints | Over a pool's hourly limit |
| 500 | Internal server error | All | Server failure |
Each endpoint's own messages are in its table on Server API and Send API.