Errors and retries
Format
Section titled “Format”Errors come as application/problem+json (RFC 9457). Tell them apart by the code field, not by the text and not by type.
{ "type": "about:blank", "title": "Conflict", "status": 409, "code": "event_id_conflict", "detail": "Event evt_90114 was already accepted with a different body.", "request_id": "req_5Jx2Qm"}detail is an explanation for developers and may change. Quote request_id when you write to us about a problem. For invalid_request, errors lists what is wrong: a pointer to the field and a detail.
| Code | HTTP | When | Retry? |
|---|---|---|---|
invalid_request |
400 | body or parameters don’t match the schema | no, fix the request |
occurred_at_in_future |
400 | occurred_at is more than 5 minutes ahead |
no, check the clock |
invalid_api_key |
401 | the key is missing or wrong | no |
invalid_signature |
401 | the event signature is wrong | no, fix the signature |
timestamp_out_of_tolerance |
401 | the signature timestamp is more than 5 minutes off | yes, with a new timestamp |
invalid_widget_token |
401 | the widget token is wrong or expired | issue a new token |
not_found, event_not_found, user_not_found, reward_not_found |
404 | the object does not exist, including in the other mode | no |
event_id_conflict |
409 | the event_id was already accepted with a different body |
no: it is a different event, give it another event_id |
reward_not_available |
409 | the reward’s status does not allow the action | no |
reward_order_mismatch |
409 | the reward is held by another order | no |
payload_too_large |
413 | the body is over 64 KB | no |
unsupported_media_type |
415 | wrong Content-Type |
no |
rate_limited |
429 | more than 50 requests per second | yes, after Retry-After |
internal_error |
500 | a failure on our side | yes |
service_unavailable |
503 | temporarily unavailable | yes, after Retry-After |
Safe retries
Section titled “Safe retries”Retrying requests is safe: we recognize a retry by its natural key.
| Request | Retry key |
|---|---|
POST /v1/events |
event_id |
POST /v1/users |
user_ref |
reserve, redeem, release |
order_id |
DELETE /v1/users/{user_ref} |
user_ref |
On a timeout, 429 and 5xx, retry with a growing pause, for example 1, 2, 4, 8 seconds and on up to a minute, with some random jitter. The exception is reserve at checkout: see Checkout.
Events: at least once
Section titled “Events: at least once”Send events at least once: if you didn’t get 202, retry with the same event_id and the same body. The most reliable way is a queue on your side: write the event to your database together with the order, and let a separate process send it to us and retry until 202. Then the event isn’t lost even if Zirva or the network was down.
Compatibility
Section titled “Compatibility”Within /v1 the contract only grows: new response fields, new enum values, new error codes and webhook types. Skip unknown fields and values instead of failing on them.