Skip to navigation

Errors & rate limits

What the API returns when something goes wrong, and how fast you can call it.

Rate limits

SettingValue
Limit100 requests per credential (API key). The TradeGuard web dashboard gets 600 requests per dashboard session, because one dashboard page makes many API calls.
WindowSliding 60 seconds
Applies toEvery authenticated /v1 request. GET /health is not limited.
Keyed byCredential: each API key, and each dashboard session, has its own budget. Two keys of the same organization do not share one.

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:

HeaderMeaning
X-RateLimit-LimitRequests allowed per window (100).
X-RateLimit-RemainingRequests left in the current window.
X-RateLimit-ResetUnix time in seconds when the oldest request in your window expires, which is when at least one more request becomes available.

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:

HTTP/1.1 429 Too Many Requests
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1790000012
Retry-After: 12
Content-Type: application/json
{
"error": "Rate limit exceeded: 100 requests per 60s. Retry after the number of seconds in the Retry-After header.",
"code": "rate_limited",
"requestId": "3f1d2c9e-…"
}

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:

codeWhen
reextraction_limit_reachedMore than 10 re-extractions of the same document within 24 hours.
llm_budget_exhaustedYour organization’s daily extraction budget is used up.

Neither sends Retry-After. Retrying immediately will fail the same way.

Errors

Every error response, at every status, has this body:

{
"error": "Subcontractor not found: 7f3c1b52-…",
"code": "not_found",
"requestId": "3f1d2c9e-…"
}
FieldMeaning
errorA human-readable message. Show it to people or log it. Its wording may change, so don’t parse it.
codeA stable, machine-readable code. Branch on this.
requestIdThe same value as the x-request-id response header. Include it when you contact support.
detailsPresent on validation_failed (and some 409s): a list of { "path", "message" }, one per invalid field.

Codes

StatuscodeMeaningRetry?
400validation_failedA field in the body, form upload or query is missing, invalid or not recognized. details names each field. A common cause: date filters need a full UTC date-time such as 2026-12-01T00:00:00Z, so a bare 2026-12-01 is rejected. This includes an upload’s file (missing, empty, or an unsupported or mismatched type).No, fix the request.
400invalid_identifierAn id in the path or query is not a valid UUID.No
400bad_requestThe request can’t be read or can’t be carried out as sent, e.g. an unparseable JSON body, a sourceUrl that can’t be downloaded, or a precondition that isn’t met (such as attaching a profile to an inactive subcontractor).No
401unauthenticatedMissing, malformed, expired or revoked credential.No, fix the credential.
403forbiddenThe credential is valid but lacks the scope or role for this action.No
404not_foundThe resource doesn’t exist, or doesn’t belong to your organization. The API never reveals whether another organization’s resource exists. Organization not found in this environment usually means an organization ID from the other environment: the sandbox has its own ID, which GET /v1/organizations returns.No
405method_not_allowedThe path exists but not for this HTTP method, e.g. PUT on a subcontractor (use PATCH). The Allow header lists the methods it supports.No, use an allowed method.
409conflictConflicts with current state, e.g. an upload of the same document that is still in progress, or a report already in flight. Creating a subcontractor whose email or phone matches one you already have returns this too, with the subcontractor’s id in details (path subcontractorId) and the field that matched.After the state changes
409assignment_existsThe subcontractor already has a live assignment on this project. The existing assignment’s id is in details (path assignmentId).No
409project_not_readyThe project’s setup is not Ready (a COI-required project needs its project number), so it cannot take assignments yet.After setup is completed in the dashboard
409subcontractor_matchA new subcontractor’s email or phone matches one already on TradeGuard, so nothing was created or linked. The message names it, and its id is in details (path existingSubcontractorId).Yes: resend with that existingSubcontractorId to add it, or with createNew: true if it’s a different company
410portal_link_expiredA sub portal link is past its expiry date (sub portal only).Yes: ask for a fresh link with POST /portal/link-requests, or for an upload link, ask the company that sent it
410portal_link_usedA sub portal link already opened the portal on another device (sub portal only).Yes: ask for a fresh link with POST /portal/link-requests
409project_documentThe action applies to baseline documents, and this document is a project certificate filed to a project slot.No
410goneThe resource existed but has expired, e.g. an invite link.No
413payload_too_largeThe uploaded file is over the size limit.No
422unprocessableWell-formed but rejected by a business rule, e.g. an upload rejected as malware (the EICAR test file), an invalid EIN or an invalid license set. For a subcontractor’s EIN and licenses, details names the field (ein, licenses, or licenses.0.licenseNumber).No
429rate_limitedOver the request rate limit.Yes, after Retry-After.
429reextraction_limit_reached, llm_budget_exhaustedExtraction limits (see above).Later
500internal_errorUnexpected server error. It has been reported to us.Yes, with backoff, for idempotent requests.
502bad_gatewayAn upstream provider, e.g. an email or document service, rejected the request. Nothing was sent.Yes, with backoff.
503service_unavailableA dependency (email, document storage, workflows) is temporarily unavailable, or the request collided with a concurrent update. Honors Retry-After.Yes, with backoff.
503sandbox_unavailableA sandbox key (or sandbox mode) was used against a deployment where the sandbox is not provisioned.No — contact support.

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.