Errors
One error shape for every failure, a stable code for your program, and the fix for each code.
The error shape
Every error has the same shape. code is stable for your program, message is for people, and fields appears only on errors about inputs:
{ "error": { "code": "validation_failed", "message": "…", "fields": { "variants.0.sku": ["…"] } } }messagefollowsAccept-Language: Arabic by default, or English withAccept-Language: en.fieldsnames each invalid input by its path in the body or the query, such asvariants.0.skuorimages.1.url.- Branch on
code, never onmessage.
Codes, meanings and fixes
The codes an integration meets:
| Code | Status | What it means and what to do |
|---|---|---|
unauthenticated | 401 | No Authorization header. Add it. |
invalid_token | 401 | Wrong, revoked or expired key. Ask the owner for a new key; do not retry. |
feature_locked | 402 | The store is not on Pro (feature: public_api), or another feature is missing (webhooks, abandoned_carts). |
ip_not_allowed | 403 | Your server is not in the key's address list. |
insufficient_scope | 403 | The key lacks the route's scope; scope names it. |
store_suspended | 403 | The store is suspended: reads work, writes are refused. |
not_found | 404 | No row with that id or SKU in this store. |
validation_failed | 422 | Invalid input; fields names each field by its path in the body. |
customers_scope_required | 422 | An order for a customer by mobile without customers.read; send customer_id or add the scope. |
invalid_transition | 422 | A status move that is not allowed; from and to. |
idempotency_key_reused | 422 | An Idempotency-Key used with a different body. |
duplicate_request | 409 | The same call with the same key is still running; retry in a moment. |
out_of_stock | 409 | Not enough stock for the order's lines; items lists them. |
insufficient_stock | 409 | A decrement below zero; available holds what is on hand. |
channel_order_cancel_remote | 409 | An order from a marketplace channel cannot be cancelled through the API: cancel it on the marketplace. |
customer_exists | 409 | The store has a customer with that mobile; customer_id names it. |
rate_limited | 429 | Past the per-minute limit; wait Retry-After. |
images_queue_full | 429 | 50 picture links wait to be copied in the store; wait Retry-After. |
server_error | 500 | An unexpected failure on our side. Retry with growing waits and the same Idempotency-Key; if it lasts, write to support with the time of the call. |
Less frequent codes
| Code | Status | What it means |
|---|---|---|
wallet_insufficient | 402 | The wallet is too low for a carrier label. |
plan_limit | 422 | The plan's limit is reached, such as the number of webhooks. |
stock_managed_by_codes | 422 | A digital card product's stock is its unsold codes and cannot be adjusted through inventory/adjustments. |
too_many_variants | 422 | The options make more variants than a product may have. |
shipment_cancelled | 422 | The label of a cancelled shipment (GET /shipments/{id}/label). |
validation_failed on cursor | 422 | A cursor this API did not write, or one changed on the way: pass meta.next_cursor back exactly as it came. |
method_not_allowed | 405 | The path exists but not with this method. Check the method in the reference. |
payload_too_large | 413 | The request body is too large, such as an upload. |
forbidden | 403 | Any other refusal, with the reason in message. |
http_error | Its own status | Any other HTTP error; the status and message say which. |
Picture copy errors
A picture link is copied after the answer, so its failure is not an error answer: the link stays in the product's images_pending with status failed and one of these in error:
error | What happened and what to do |
|---|---|
image_unreachable | The link could not be fetched as a picture: a name that resolves to a private address, or a file that is not a JPEG, PNG, WebP or GIF of at most 15 MB. Fix the link. |
too_many_images | The product already had 10 pictures by the time the copy finished. |
copy_failed | The copy job stopped, or ran out of time before this link (a job downloads for 60 seconds at most, 10 per link): send the link again in a new write. |
Extra keys by code
Some codes carry extra keys inside error:
| Key | Sent with | What it holds |
|---|---|---|
fields | validation_failed, insufficient_stock, stock_managed_by_codes | Per-field messages, keyed by the input's path in the body or query. |
available | insufficient_stock | The quantity on hand of the refused line (fields names it). |
customer_id | customer_exists | The store's customer that already has this mobile. |
scope | insufficient_scope | The scope the key lacks. |
feature, required_plan | feature_locked | The plan feature the call needs, and the cheapest plan that includes it. |
items | out_of_stock | The indexes of the order lines without enough stock. |
from, to | invalid_transition | The order's current status and the status asked for. |
By HTTP status
- 401, 402, and 403
ip_not_allowedorstore_suspended: refused before the rate count, so they carry noX-RateLimit-*headers and do not use your limit. - 403
insufficient_scope: checked after the count, so it carries the headers and counts. - 409: a conflict to retry (
duplicate_request) or a stock or customer conflict to handle. - 422: fix the input, then send it with a new Idempotency-Key: 4xx answers are replayed as they were for the same key.
- 429: wait
Retry-Afterseconds. See Rate limits and retries. - 5xx: retry with growing waits and the same Idempotency-Key; 5xx answers are not kept against it.