Skip to main content
Bachs uses conventional HTTP status codes to indicate the result of a request. A 2xx code means success. A 4xx code means the request failed given the information provided, such as a missing field or a declined payment. A 5xx code means something went wrong on our side; these are rare.

The error object

When a request fails, the API returns a flat error object instead of the resource. Branch on error_code, which is stable, rather than on detail, which is a human-readable message that may change.
string
required
Stable, machine-readable code. Always present. Look it up in the Error Reference.
string
required
Human-readable description of what went wrong.
string
required
Link to this code’s entry in the Error Reference.
array
Present on validation errors only. One entry per field that failed, each with field, message, and type.
object
Present on limit errors only. Structured context such as requested_amount and max_allowed_amount.

Validation errors

A VALIDATION_ERROR adds an errors array naming each field that failed, so you can surface the message next to the right input.

HTTP status codes

For every error_code and what to do about it, see the Error Reference.

Request ID

Every response, success or error, includes an x-request-id header.
Log it, and include it when you contact support. It is the fastest way for us to locate your exact request.

Handling errors

1

Branch on error_code

Use error_code, not detail or the HTTP status alone, to drive your logic. It is stable across releases.
2

Surface validation messages

For VALIDATION_ERROR, show each errors[].message next to its field in your form.
3

Retry transient failures safely

On 429 or a 5xx, back off and retry. For POST requests, reuse the same Idempotency-Key so the retry cannot double up.
Rate limits and back-off headers (Retry-After, X-RateLimit-Reset) are documented on API Standards.