Errors
Every error has one shape: a stable code, a sentence, the field it's about and a request id. What each code means, and what to do.
When something goes wrong, the API answers with a status code and a JSON body in one shape, whatever the endpoint:
{
"error": {
"code": "missing_scope",
"message": "This key doesn't have the \"write\" scope.",
"param": null,
"request_id": "rqi_7k3m9q2wx8hd4rtn"
}
}
codeis stable. Match on it in your code.messageis one sentence for people, so you can show it or log it. Don't match on its words; they may get clearer.paramnames the input field a400is about, likestatusorto.id. Null when it isn't about one field.request_idis the same as the answer'sRequest-Idheader.
Request ids
Every answer has a Request-Id header, like rqi_7k3m9q2wx8hd4rtn, whether it worked or not. Log it. For an answer that went wrong (any status from 400 up), we keep one line with the request's id, your key's id, the operation, the status and the error code, and nothing else: never the body or what it was about. Write to us with that id and we can find what happened.
Codes
| Code | Status | What happened | What to do |
|---|---|---|---|
invalid_request | 400 | Something in the request is missing or not allowed | Fix the request. param names the field |
invalid_json | 400 | The request body isn't valid JSON | Send a JSON body with Content-Type: application/json |
unauthorized | 401 | No key, or the key is wrong (a typo fails its checksum), revoked, or the person who made it is no longer on the team | Check the Authorization: Bearer rookery_… header. See Keys and scopes |
missing_scope | 403 | The key doesn't have the scope this needs | Make a key with that scope. See Keys and scopes |
test_key_only | 403 | A live key called something only the sandbox does | Use a test key. See Sandbox |
plan_required | 403 | The workspace's plan doesn't include this | The API is on Pro and Team |
not_allowed | 403 | The key may not do this here, like approving a draft the key or its person wrote, or one on a confidential conversation | A person approves it in Rookery |
not_found | 404 | No such thing, or one the key can't see (for a test key, anything outside the sandbox) | Check the id. Someone else's private inbox always answers 404 |
conflict | 409 | It conflicts with how things stand now, like approving a draft with a version from before Rook wrote it again | Read it again, then decide |
idempotency_key_reused | 422 | Reserved for when Idempotency-Key arrives: the same key came with a different body | Not sent today |
rate_limited | 429 | More than about 120 requests in a minute with this key; for POST /sandbox/inbound, 120 simulated emails in a minute across the sandbox; or more than 10 wrong keys in a minute from one address | Wait Retry-After seconds. See Rate limits |
internal_error | 500 | Something went wrong on our side | Try again shortly. If it keeps happening, write to hello@userookery.com with the request id |
unavailable | 503 | Rookery is busy or down for a moment | Wait Retry-After seconds, then try again |
New codes may appear. Treat one you don't know by its status.
Bad input
A 400 for bad input lists every problem at once in message, separated by semicolons, each starting with its field. param names the first:
{
"error": {
"code": "invalid_request",
"message": "status: Invalid option: expected one of \"open\"|\"waiting\"|\"closed\"; id: A conversation id looks like cnv_…",
"param": "status",
"request_id": "rqi_2h8q4w7m9kx3drtb"
}
}
Each endpoint's fields, with their limits, are in the API reference.
On the MCP server
A tool that fails answers with isError: true and the same error body, as JSON text and as structuredContent, so an agent can read the code and fix its call. Problems with the request itself (not JSON-RPC, an unknown method) keep JSON-RPC's own error shape. See MCP.
Retrying
Retry a 429, a 500 or a 503, and a timeout or dropped connection, after a wait: Retry-After says how long for a 429 or a 503. Before retrying a request that creates something, like a note or a reply, read Retries: a retry can make a second one.