Handle errors and uncertain outcomes
Check both the HTTP status and the JSON response. Ordinary AntAPI JSON APIs use a code, data, and error envelope. Successful requests use code 0 and an empty error string; data is the endpoint-specific payload. Failures use a stable nonzero code and a human-readable error. Do not branch on translated error text.
This is an illustrative envelope only, not a complete product response:
{
"code": 0,
"data": {},
"error": ""
}
Use the generated API Reference for endpoint-specific payloads and errors. An HTTP 202 is an accepted asynchronous operation. An HTTP 200 result page can contain failed or inconclusive items; inspect the individual item fields.
Choose a recovery action
| HTTP status | What to check | What to do |
|---|---|---|
400 | Request shape, input, or parameters. | Correct the input before trying again. |
401 | Missing, invalid, revoked, or unavailable project credentials. | Check the key and organization/project state. |
402 | Eligible balance or reservation requirements. | Check balance, debt and the reservation required for the operation. |
404 | Published route or resource identity in the current project scope. | Verify the path, job ID, and project. |
409 | Changed input under the same key, or original operation still in progress. | Read the error; keep the original key for an unchanged retry. |
429 | Request rate, concurrency, or project budget limits. | Check budget, reduce concurrency or back off as appropriate, and honor Retry-After when provided. |
502 | Upstream connection or response safety failure. | Treat execution as potentially uncertain and preserve the original operation identity. |
503 | Published snapshot or settlement temporarily unavailable. | Back off and follow the original operation’s recovery contract; do not create a new paid operation. |
504 | Upstream timeout. | Do not assume no work ran; recover using the original key or job ID. |
Product-specific errors can provide more detail than this Gateway overview. Use the product guide for its source availability and item outcome semantics; an inconclusive result does not establish a successful item.
When the outcome is unknown
If a batch create request times out before you receive a job ID, repeat the same POST with its saved Idempotency-Key, body, and query. If you already have the job ID, use progress and result requests. These reads do not create another batch or add lookup charges.
For synchronous calls, a stable idempotency key preserves the recorded financial outcome, but does not guarantee that the original response body can be replayed. Do not silently create a new paid operation just to recover a lost body.
The platform keeps the original reservation while it recovers authorized execution. Client disconnection and HTTP timeout do not cancel work. Cancellation stops future batch work; successful items can still settle.
For an accepted trustworthy Completion in settlement_pending, the original Hold remains protected while settlement retries, including its original UTC month. Timeouts do not establish free usage, and the ordinary safety deadline does not release an accepted Completion’s Hold. Never automatically create a new paid operation with a new key to recover a missing response. See Balance and billing for reservation and settlement rules.
Collect useful diagnostics
Record the HTTP status, stable error code, X-Request-ID, timestamp, and batch job ID where available. Follow Usage and receipts to find the matching request and final charge in Console. A technical failure can still have a charge receipt, and a missing final receipt does not confirm zero cost. Remove Authorization headers, API keys, cookies, request bodies, and sensitive result data from shared diagnostics.