Skip to content
Select theme
Light
Dark
Auto
Select language
English
فارسی

Errors and limits

Every Kaladan API reports trouble in two different ways, and telling them apart is the first thing a client has to get right.

The operation did not run. The response has a top-level errors array and data: null, and an HTTP status that says why. Fix the request, or retry it when the code says retrying helps.

{
"data": null,
"errors": [
{
"message": "This request needs more points than are available.",
"extensions": { "code": "MAX_COST_EXCEEDED" }
}
]
}

The codes are a closed list. A client can switch on all of them:

CodeWhat it meansWhat to do
BAD_REQUESTThe document or its variables are malformed.Fix the request.
UNAUTHENTICATEDNo credential, an expired one, or one for another shop.Refresh the token, or check the host.
ACCESS_DENIEDThe credential is valid but may not do this.Do not retry.
SCOPE_ESCALATIONAn app asked for fields outside its grant. missing lists which scope each one needs.Ask the merchant to approve a version that declares them.
NOT_FOUNDThe thing addressed does not exist, or this caller may not know it does.Do not retry.
THROTTLEDToo many requests.Wait for Retry-After.
MAX_COST_EXCEEDEDThe query costs more than the bucket holds.Wait for Retry-After, or ask for less.
SHOP_UNAVAILABLEThe shop is not serving: extensions.reason is STORE_LOCKED or SUSPENDED.Show the shop as closed.
API_VERSION_UNSUPPORTEDThe version in the path is not served. Today this arrives as a plain 404.Move to a supported version.
INTERNALSomething failed on Kaladan’s side.Retry with backoff; report it if it persists.

Every response carries an X-Request-Id header. Log it: it is what to quote when you ask for help.

The operation ran, decided, and declined: a quantity over the stock, a code that expired, a field that failed validation. These arrive on a 200, inside the mutation’s payload:

mutation {
cartLinesAdd(cartId: "…", lines: […]) {
cart { totalQuantity }
userErrors { code field params message }
}
}
  • A non-empty userErrors means nothing changed. There are no partial writes to reconcile.
  • Switch on code and read params. message is English, for your logs. It is never meant for a buyer or a merchant; write your own words from the code.
  • field is a path into the input you sent, so a form can mark the field that was refused.

The shared codes are REQUIRED, MIN_LENGTH, MAX_LENGTH, PATTERN, OUT_OF_RANGE, ENUM, LIST_SIZE, INVALID, INCONSISTENT, NOT_FOUND, FORBIDDEN, EXPIRED, UNAVAILABLE, INSUFFICIENT_STOCK, CODE_INVALID, NOT_APPLICABLE, INVALID_STATE, IDEMPOTENCY_CONFLICT and RATE_LIMITED.

Cart mutations can also return warnings on success: a quantity trimmed to stock, a line dropped because its product was unpublished. Read them, or you show a buyer a cart they did not agree to.

Each credential has a bucket of 2,000 points that refills at 100 points a second. A request is charged before it runs, from the query document itself:

  • each object field costs 1;
  • a connection costs its first or last, and nesting multiplies;
  • a scalar leaf costs nothing.

What the response did not use is refunded afterwards, and every response says what happened:

{
"extensions": {
"cost": {
"requestedQueryCost": 152,
"actualQueryCost": 46,
"throttleStatus": {
"maximumAvailable": 2000,
"currentlyAvailable": 1954,
"restoreRate": 100
}
}
}
}

Asking for first: 250 and drawing ten is charged for 250 up front, because the capacity was reserved for 250. Ask for the page you will show.

Mutations that move money or stock (cartCheckoutStart, for one) take an idempotencyKey. Send the same key when you retry and the operation runs at most once. Keys are remembered for 24 hours, and reusing one with a different input is IDEMPOTENCY_CONFLICT.

Lists are cursor-based: first and after forward, last and before backward, never both. A page holds at most 250 items, and asking for more is OUT_OF_RANGE rather than a quiet truncation. Conventions explains sorting and why changing the sort retires your cursor.