2xx responses mean success, 4xx mean a problem with the request and 5xx mean a problem on Routa’s side.
Error format
API errors share the same structure, in the style of the payment APIs you probably already know:code is part of the contract: it is never renamed. New codes can be added at any time, so handle unknown codes generically, using type and the HTTP status.request_id also comes in the Routa-Request-Id header of every response.
Actionable details
Some errors carrydetails with values you can use in your code:
Error types
billing_error uses 402, never 429. Clients retry 429, but waiting does not increase the allowance of a plan.HTTP status codes
Malformed request
When the body, the query or the path do not have the documented format, for example because a required field is missing or a field has the wrong type, the API responds422 request_invalid:
param names the field, such as template.button_parameters.0.index. It is absent when the API cannot point at a field, and it never repeats a key you made up, such as one in metadata. The response does not return the value you sent.
A body that is not valid JSON gets a plain text 400 (Bad Request), without the error object.
How to handle each error
4xx (except 409 and 429): fix the request
4xx (except 409 and 429): fix the request
Trying again without changing anything is pointless. Read
code, param and message, fix it and send another request. The exception is 409 idempotency_in_progress, which is worth a new attempt.429: wait and try again
429: wait and try again
Respect the
Retry-After header and use exponential backoff with jitter. See Rate limits.5xx: try again with the same idempotency key
5xx: try again with the same idempotency key
Failures on Routa’s side are safe to retry if you use
Idempotency-Key. Resend with the same key. See Idempotency.Network failure or timeout
Network failure or timeout
You do not know whether the request arrived. Resend with the same
Idempotency-Key. It guarantees there is no duplicate message.