Skip to content

Every error is JSON with an error message:

{ "error": "NPI must be 10 digits." }

Some errors add a machine-readable code:

{ "error": "Too many requests. Try again in 23s.", "code": "RATE_LIMITED" }

code is present on 429 (RATE_LIMITED, or REFRESH_BUSY when a workspace already has two refreshes running), on 413 (TOO_LARGE), on 502 from Ask (ASK_FAILED) and on errors from the sign-in endpoints under /api/auth/. Other errors have only error.

The message is written to be shown to a person. Branch on the status code, and on code where there is one, not on the text.

Status Meaning What to do
400 The request is malformed, has a field the endpoint does not take, or an export could not run Fix the request; the message says how. Not charged.
401 Missing, unknown, revoked or expired token See Authentication
402 Out of credits for the month Wait for the monthly reset or raise your limit. See Credits.
403 Not a member of the workspace named in X-Oph-Workspace; key management called with an API key or by a member; a dashboard saved, renamed or deleted by an API key, or changed by a member who does not own it; /api/profile called with an API key See Authentication, Roles and who can do what
404 No provider, hospital, group, key, dashboard, dashboard tile or catalog dataset with that id or name. A dashboard in another workspace answers 404 too. So do the removed endpoints: POST /api/sql and everything under /api/queries. Check the id. Lookups that miss are not charged.
409 The workspace already has 20 active API keys or 200 saved dashboards; a dashboard with no tiles was refreshed Remove one first, or see Saved dashboards
413 Request body larger than 64 KB, or 8 KB under /api/profile Send a smaller body. See Request size.
429 Rate limited Wait the number of seconds in Retry-After. See Rate limits.
502 Ask in JSON mode: the model could not plan an answer. code is ASK_FAILED and charged is false. Rephrase the question, or name the procedure, drug or state you mean. Nothing was charged.
500 Internal error. Retry once. If it repeats, check /api/health.

The MCP server reports errors differently: JSON-RPC errors for protocol problems, and tool results marked isError for failed tool calls.

A request under /api/ passes these checks in order, and stops at the first that fails:

  1. Rate limit per client address (429)
  2. Request size (413)
  3. Authentication and workspace (401, 403)
  4. Rate limits per workspace (429)
  5. Credit pre-check, on metered endpoints only (402)
  6. The endpoint’s own validation and work (400, 404, and 402 if this call would pass the limit)

Two consequences:

  • A workspace that has already spent its allowance gets 402 from every metered endpoint before the request is validated or anything runs. See Running out.
  • Requests that fail authentication still count against the per-address limit.

No endpoint and no MCP tool takes SQL. POST /api/sql and /api/queries answer 404, POST /api/exports answers 400 to a body with a sql field, and the endpoint that renames or saves a dashboard answers 400 to any field other than name and saved. The sql fields in responses are receipts.

Once /api/ask starts streaming, the HTTP status is already 200. Failures arrive as events:

  • tile_error: one tile failed. Others still arrive, and done reports the count in failed. A free refresh of the stored dashboard retries it.
  • error: the answer could not start. With code: "ASK_FAILED" and charged: false, the model could not plan and nothing was charged; with status: 402, the balance ran out before the charge. The stream ends. See errors inside the stream.

In JSON mode the same failures are ordinary responses: failed tiles are listed in failed, and a failed plan is a 502.

Requests are rate limited. The limits stop bursts and runaway loops; the hard cap on spend is still your credits.

Applies to Limit Counted per
Every request under /api/, including public and sign-in endpoints 900 per minute Client address
Every authenticated request under /api/ 300 per minute Workspace
/api/ask, together with the MCP ask tool 10 per minute Workspace
POST /api/exports (listing with GET counts only toward the 300) 10 per minute Workspace
Refreshing a dashboard 20 per minute, and 2 running at once Workspace
/api/catalog 240 per minute Workspace
/api/catalog/search 180 per minute Workspace
/api/catalog/:table/sample 40 per minute Workspace
/api/profile: 120 updates, 90 lookups, 12 market summaries, 6 suggestion builds per minute See left Signed-in person
/mcp 120 per minute API key and client address together

How they combine:

  • Limits stack. A call to /api/ask counts against the per-address limit, the workspace’s 300 and the workspace’s 10. It must be under all three.
  • Workspace limits are shared. Every key and every signed-in member of a workspace draws on the same counters.
  • Rejected requests count. A request that gets 429 still counts toward the limits checked before it and the one that rejected it, though it cannot extend the window.
  • Windows are fixed. A window starts at the first request and lasts 60 seconds. The count returns to zero when it ends; it is not a sliding average.

Responses carry the state of one limit:

Header Meaning
RateLimit-Limit Requests allowed per window
RateLimit-Remaining Requests left in the current window
RateLimit-Reset Seconds until the window ends
Retry-After Only on 429: seconds to wait. Same value as RateLimit-Reset.

When several limits apply, the headers describe the last one checked. On a successful call that is the most specific: the 10 on /api/ask, the 300 on /api/providers, the 900 on a public endpoint such as /api/health. The refresh limit is the exception: a successful refresh reports the 300, and only its 429 reports the 20. On a 429 they describe the limit that rejected the request. On a 401 they describe the per-address limit, because the workspace is not yet known.

HTTP/1.1 429 Too Many Requests
RateLimit-Limit: 10
RateLimit-Remaining: 0
RateLimit-Reset: 23
Retry-After: 23
{ "error": "Too many requests. Try again in 23s.", "code": "RATE_LIMITED" }

Nothing is charged for a 429. Wait Retry-After seconds, then retry.

The sign-in and workspace endpoints under /api/auth/ have their own limits, counted over 10 minutes. Where an email is involved, the limit applies per client address and per email address separately.

Action Per address Per email
Password sign-up 20 8
Password sign-in 20 8
Sending a code (POST /api/auth/code) 10 4
Checking a code (sign-in, verify and reset together) 30 10
Creating a workspace 10
Creating an invitation 30
Accepting or rejecting an invitation 30

Past one of these, the response is 429 with Retry-After and a body such as { "error": "Too many attempts. Try again in 412s.", "code": "RATE_LIMITED" }. The RateLimit-* headers on these endpoints describe the general per-address limit, not these.

  • Counters are in memory, per server instance. On one long-running server the limits are exact. With several instances behind a load balancer, a client can get up to that many times each limit, and a restart clears the counters. The credit ledger is in Postgres and is exact everywhere.
  • The client address comes from X-Forwarded-For, counted from the right. Set TRUSTED_PROXY_HOPS to the number of proxies in front of the server. The default is 1: the address is the last entry in the header, the one your own proxy appended. With 0 the header is ignored and the socket address is used. A wrong value either lets clients choose their own address or puts every client behind one address.

A request body under /api/ can be at most 64 KB. A larger one gets:

{ "error": "Request body is too large (64 KB limit).", "code": "TOO_LARGE" }

with status 413. This is checked before authentication. The MCP endpoint has its own limit of 256 KB, and the profile endpoints a smaller one of 8 KB, checked after authentication.