Errors
Every error shape the API returns, and how to tell them apart.
Every error the API returns has the same JSON body — an error message and a code — and a meaningful HTTP status. Read the status for the category, code to branch on, and error for the human-readable detail. The same shape comes back from the Lambda handlers, the FastAPI worker, and the API gateway itself.
The error shape
{ "error": "Index 'idx_bp1RRYPJpNWb' not found.", "code": "not_found" }
error and code are always strings. A few fields appear when they add something more:
| Field | When | What it is |
|---|---|---|
error | Always | Human-readable message. Safe to show a user or log. |
code | Always | A stable machine string to branch on: the status's own code (table below), or a more specific one — billing_required vs payment_failed, invalid_api_key, or the Cognito exception on a sign-in failure. |
action | Plan refusals | What the plan does not allow, on a billing_required 402 — e.g. backtests, live, restatements, api. |
issues | Validation 422s | An array of structured problems (severity, code, message, path, operation_id) when a workflow fails validation. |
A sign-in failure carries a code so you can tell a wrong password from an unconfirmed account without parsing the message:
{ "error": "Incorrect username or password.", "code": "NotAuthorizedException" }
A workflow that fails validation (on POST /workflows, POST /simulate or POST /execute) returns a summary in error and the detail in issues:
{"error": "Fix these validation issues and retry.","code": "validation_failed","issues": [{"severity": "error","code": "MISSING_INPUT_WIRING","message": "operation 'filter_dataframes' has no wired input","path": "operations[2].inputs","operation_id": "filter_dataframes"}]}
Status codes
| Status | `code` | Means | What to do |
|---|---|---|---|
400 | invalid_request | Malformed request — bad JSON, missing a required field | Fix the request; do not retry it unchanged |
401 | unauthenticated, invalid_api_key | Missing or invalid credentials — the API key, a Cognito token, sign-in or refresh | Check the key; re-authenticate. Send the token raw — a Bearer prefix also 401s |
402 | billing_required, payment_failed | The team's plan does not include this or a plan limit is reached (action says which) — or a card was declined | Upgrade, or update the card, on the billing page, then retry |
403 | forbidden | Authenticated, but not allowed — not a member of the team, or the resource's owner has not shared it with you | Act as a team that owns it, or ask the owner to share it |
404 | not_found | Unknown resource id — or no such route | Check the id and its prefix (idx_, dlv_, dst_, …), and the method and path |
409 | conflict | The request clashes with the resource's state — it already exists, or changed since you read it | Refresh, then decide whether to retry |
422 | validation_failed | Well-formed but failed validation | Read issues, fix each, and retry |
429 | rate_limited | Rate limited | Honour Retry-After and back off |
5xx | internal_error, upstream_error, timeout | Server, worker or upstream failure | Retry with backoff; if it reproduces, the request itself is likely the cause |
An unknown route is a 404
404 with {"error": "No such route. Check the method and the
path.", "code": "not_found"} — usually a stray /prod in the URL or a typo. See Base URLs.Operations run through POST /execute
403, 404, 402) with the usual body. A request that runs several answers 200, and each
operation reports its own outcome in state.error and state.code — one refusal does not void the rest.Handling errors
Because there is one shape, one helper covers everything: on a non-2xx, branch on code and show error. All 4XX/5XX responses — including a gateway key rejection — carry CORS headers, so a browser fetch can read the status and body rather than failing with an opaque network error.
def error_message(response):"""Return the error string, or None if the request succeeded."""if response.ok:return Nonetry:return response.json().get("error") or f"HTTP {response.status_code}"except ValueError:return f"HTTP {response.status_code}"
Log the raw body
issues array is the whole diagnosis. A 5xx body never carries internals — it is a generic message by design.