GladysDevelopers

Errors

How the API reports what went wrong, and what to do about it.

The API uses HTTP status codes to say what kind of failure happened, and a JSON body to say which one:

{
  "success": false,
  "error": {
    "code": "BAD_REQUEST",
    "message": "return_url must be one of the client's registered redirect URIs",
    "details": { "return_url": "not a registered redirect URI for this client" }
  }
}

message is written to be read by a person: log it, and show it where it helps. details, when present, names the fields at fault. Branch on the HTTP status and code, never on the message text, which may change.

StatuscodeMeansWhat to do
400BAD_REQUESTThe request is invalid, or not allowed in the payment's current state, e.g. capturing a payment nobody approved.Fix the request. Retrying it unchanged will fail again.
401UNAUTHORIZEDThe access token is missing, expired or revoked.Get a new access token.
403FORBIDDENYour token is valid but lacks the scope, or the app can't do this (e.g. it isn't registered to a business).Check the app's scopes and setup.
404NOT_FOUNDIt doesn't exist, or belongs to another app.Check the reference.
409CONFLICTSomething else changed the payment at the same moment, e.g. two captures at once.Read the payment again, then decide.
400IDEMPOTENCY_KEY_REQUIREDThe request moves money and carried no Idempotency-Key.Send one. See Idempotency.
409IDEMPOTENT_REQUEST_IN_FLIGHTA request with this Idempotency-Key is still running.Wait a moment, retry with the same key.
422IDEMPOTENCY_KEY_REUSEDAn Idempotency-Key was reused for a different request.Use a new key. See Idempotency.
429Too many requests.Wait, then retry. See Rate limits.
503IDEMPOTENCY_UNAVAILABLEWe couldn't check the request for duplicates, so nothing ran.Retry with the same Idempotency-Key after Retry-After.
500INTERNAL_SERVER_ERROR, DATABASE_ERRORSomething went wrong on our side.Retry with the same Idempotency-Key.

Other shapes

A few responses come from layers in front of the endpoints and are shaped differently. Check the status first and you can handle them the same way:

  • Missing or expired token, 401:
    { "error": "unauthorized" }
  • Rate limited, 429:
    { "error": "Too many requests. Please try again later.", "retry_after": 60 }
  • The OAuth endpoints (/oauth/token, /oauth/revoke, /oauth/introspect) use the standard OAuth error shape, { "error": "invalid_client", "error_description": "…" }, so OAuth libraries can read them. See Authentication.

Retrying safely

Retry 429 and 5xx responses, and network failures where you never got a response, after a short wait that grows with each attempt. For anything that creates or changes something, send an Idempotency-Key so a retry can't do it twice. Don't retry other 4xx responses unchanged.

On this page