Skip to main content
Every failed request returns a JSON body with a status and a detail:
status repeats the HTTP status code. detail is a human-readable explanation intended for logs and developers — it is not a stable identifier, so do not branch on the text of detail. Branch on the HTTP status, or on the typed error the SDK raises.

Status codes

400 and 422 both indicate the request will not succeed as sent. Broadly, 400 means the request itself was malformed, and 422 means it parsed correctly but violates a rule — for example a value that is well-formed but not valid for the current state of the resource.

Request IDs

Every response carries an X-Request-Id header — a UUID generated per request. Log it. When you contact support about a failed request, the request ID is the fastest way for us to find it — far quicker than a timestamp and an endpoint. The TypeScript SDK surfaces it as requestId on every error it raises.

Typed errors in the TypeScript SDK

The TypeScript SDK maps failed responses onto typed error classes, so you can branch with instanceof rather than inspecting status codes by hand. All of them extend AlgunaError and carry statusCode, code and requestId.
422 is not mapped to ValidationError. It arrives as ApiError with statusCode: 422. Handle both when you are validating user input.

Retrying

Retry these:
  • 429 — wait for retryAfter before retrying. If it is absent, back off exponentially.
  • 500 and other 5xx — retry with exponential backoff and jitter.
  • 409 — the earlier request with that idempotency key is still in flight. Retry with the same key; do not generate a new one, or you risk creating a duplicate.
  • Network timeouts — you do not know whether the request was applied. Retry with the same idempotency key.
Do not retry 400, 401, 404 or 422 without changing the request. They are deterministic and will fail identically.
Always send an Idempotency-Key on writes you might retry. Without one, a retry after a timeout can create a second customer, subscription or invoice. See Idempotency.

Idempotency

Idempotency keys, replay behaviour, and the 409 conflict case.

TypeScript SDK

Installation, authentication, and error handling.