Errors
Every error answers with a JSON body. Branch on code, not on the error text.
{
"error": "insufficient balance, top up to continue",
"code": "insufficient_balance",
"hint": "The prepaid balance is too low for this call. Top up, or turn on auto top-up, at https://datamaxiplus.com/dashboard/billing.",
"docs_url": "https://docs.datamaxiplus.com/api/pricing",
"request_id": "…",
"charged": false
}
| Field | Meaning |
|---|---|
error | A short message. It can change; don't parse it. |
code | A stable code from the table below. |
hint | One line on what to do next. Agents can show it as is. |
docs_url | The docs page for this error, when there is one. |
request_id | Quote it when you contact us. |
charged | Always false: only successful responses are charged. |
Error codes
| HTTP | code | What happened | What to do |
|---|---|---|---|
400 | invalid_request | A parameter is missing or not supported. error says which. | Fix the request. Check the endpoint's parameters in the REST reference. |
401 | missing_api_key | No API key on a paid endpoint. | Send the key in X-DTMX-APIKEY. See Authentication. |
401 | invalid_api_key | The key is mistyped, rotated or revoked. | Copy an active key from My page → API keys. |
401 | api_key_not_allowed | The key's account can't use this endpoint. | Check the endpoint's access, or contact us. |
401 | origin_not_allowed | A browser call from an origin that isn't accepted. | Call the API from your server with a key. |
402 | insufficient_balance | The balance can't pay for this call. | Top up, or turn on auto top-up. See When your balance runs out. |
402 | balance_expired | The balance expired 12 months after the latest top-up. | Top up to continue. |
402 | key_spend_cap | This named key reached its own spend cap. The balance is untouched. | Wait for resets_at, raise the cap, or use another key. See Spend caps. |
403 | key_ip_not_allowed | This named key has an IP allowlist and the request came from another address. | Call from an allowed address, or edit the key's allowed IPs. See IP allowlists. |
404 | not_found | Unknown path, symbol or exchange. | Check the path and the supported values. |
405 | method_not_allowed | Wrong HTTP method. | Data endpoints are GET. |
408, 504 | timeout | The request took too long. | Retry, or narrow it: a shorter time range or fewer rows. |
429 | rate_limited | Over the per-minute limit for the account. | Wait the seconds in Retry-After. See Limits. |
500 | server_error | Something went wrong on our side. | Retry in a few seconds. If it keeps failing, contact us with the request_id. |
502, 503 | service_unavailable | The service is briefly unavailable. | Retry with backoff. |
The three 402 bodies also carry balance_url, auto_topup_url, topup_url and billing_url, and a key_spend_cap body adds resets_at (RFC 3339, UTC). Treat 401, 402 and 403 as a signal to fix the key or the balance, not to retry: the same request fails until you do.
Accounts still on a legacy subscription plan can also see plan_required, subscription_expired, no_credit and credit_limit_exceeded; the hint says what to do. See Legacy subscription plans.
Over MCP
MCP tools return the same errors as the API call behind them. On insufficient_balance or balance_expired, the tool error tells the agent to call get_usage and topup. On key_spend_cap, it keeps the API's hint, because the balance is fine and only that key is capped.
WebSocket
The same checks run when a stream opens, so a refused connection answers with the codes above. An open stream is closed when the balance runs out or a named key reaches its spend cap. Top up or raise the cap, then reconnect.