Errors & rate limits
Rate limits
The window slides: a request “uses up” a slot for exactly 60 seconds after it was made. A request rejected with 429 does not use a slot, so waiting for Retry-After frees a slot for you. If you send several requests in parallel with the same key, another of your own requests can take that slot first; in that case you get a fresh 429 with a new Retry-After, so keep retrying after each one.
Headers
Every /v1 response carries these headers, including successful ones:
When you go over the limit you get a 429 response. It carries the same three headers plus Retry-After, the number of seconds to wait:
Recommended client behaviour: on a 429, sleep for Retry-After seconds and retry. Before a burst, check X-RateLimit-Remaining.
Requests without a valid credential are rejected with 401 before the limiter runs, so a 401 never carries rate-limit headers. Repeated invalid API keys from the same IP address (more than 30 in 60 seconds) get 429 with code: "rate_limited" and a Retry-After header until the window clears; requests with a valid key are not affected by this. If TradeGuard’s rate-limit store is briefly unavailable, requests are allowed rather than failed, and those responses carry no rate-limit headers.
Other 429s
One document endpoint has its own limits, separate from the request limit. They apply only to POST /v1/subcontractors/{id}/documents/{documentId}/extract, which re-runs document extraction:
Neither sends Retry-After. Retrying immediately will fail the same way.
Errors
Every error response, at every status, has this body:
Codes
New codes may be added over time. Treat an unknown code according to its HTTP status: 4xx means fix the request, 5xx means retry with backoff.
Unknown fields
Request bodies and the GET /v1/subcontractors query are checked strictly: a field the endpoint doesn’t accept is rejected with 400 validation_failed, and details names it ("message": "Unknown field \"favoriteColor\""). A misspelled field fails loudly instead of being ignored. Read-only fields such as an organization’s slug are rejected the same way on PATCH.
Requests blocked before they reach the API
TradeGuard’s hosting provider runs a web application firewall in front of the API. A request that looks like an attack, for example a value containing SQL such as '); DROP TABLE … or a file name containing ../, can be blocked there. That response does not follow the error format above: it is a 403 with an HTML page (Content-Type: text/html), no code and no requestId.
Treat any error response whose Content-Type isn’t application/json as this case: don’t retry it unchanged, and check the request for SQL-like text or path segments. Ordinary names with apostrophes, ampersands or dashes (O'Brien's Plumbing, Smith & Sons) are not blocked. If a legitimate request is blocked, contact support with the time of the request and the cf-ray response header.
Sandbox and production
Errors and limits behave identically in the sandbox, and a sandbox key has its own rate-limit budget. Two errors are sandbox-specific: 403 forbidden when a production key calls a /v1/sandbox/* helper, and 503 sandbox_unavailable if a sandbox key is used where the sandbox is not provisioned.
