Sifr Wahid Developers

Concepts

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:

JSON
{ "error": { "code": "validation_failed", "message": "…", "fields": { "variants.0.sku": ["…"] } } }
  • message follows Accept-Language: Arabic by default, or English with Accept-Language: en.
  • fields names each invalid input by its path in the body or the query, such as variants.0.sku or images.1.url.
  • Branch on code, never on message.

Codes, meanings and fixes

The codes an integration meets:

CodeStatusWhat it means and what to do
unauthenticated401No Authorization header. Add it.
invalid_token401Wrong, revoked or expired key. Ask the owner for a new key; do not retry.
feature_locked402The store is not on Pro (feature: public_api), or another feature is missing (webhooks, abandoned_carts).
ip_not_allowed403Your server is not in the key's address list.
insufficient_scope403The key lacks the route's scope; scope names it.
store_suspended403The store is suspended: reads work, writes are refused.
not_found404No row with that id or SKU in this store.
validation_failed422Invalid input; fields names each field by its path in the body.
customers_scope_required422An order for a customer by mobile without customers.read; send customer_id or add the scope.
invalid_transition422A status move that is not allowed; from and to.
idempotency_key_reused422An Idempotency-Key used with a different body.
duplicate_request409The same call with the same key is still running; retry in a moment.
out_of_stock409Not enough stock for the order's lines; items lists them.
insufficient_stock409A decrement below zero; available holds what is on hand.
channel_order_cancel_remote409An order from a marketplace channel cannot be cancelled through the API: cancel it on the marketplace.
customer_exists409The store has a customer with that mobile; customer_id names it.
rate_limited429Past the per-minute limit; wait Retry-After.
images_queue_full42950 picture links wait to be copied in the store; wait Retry-After.
server_error500An 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

CodeStatusWhat it means
wallet_insufficient402The wallet is too low for a carrier label.
plan_limit422The plan's limit is reached, such as the number of webhooks.
stock_managed_by_codes422A digital card product's stock is its unsold codes and cannot be adjusted through inventory/adjustments.
too_many_variants422The options make more variants than a product may have.
shipment_cancelled422The label of a cancelled shipment (GET /shipments/{id}/label).
validation_failed on cursor422A cursor this API did not write, or one changed on the way: pass meta.next_cursor back exactly as it came.
method_not_allowed405The path exists but not with this method. Check the method in the reference.
payload_too_large413The request body is too large, such as an upload.
forbidden403Any other refusal, with the reason in message.
http_errorIts own statusAny 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:

errorWhat happened and what to do
image_unreachableThe 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_imagesThe product already had 10 pictures by the time the copy finished.
copy_failedThe 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:

KeySent withWhat it holds
fieldsvalidation_failed, insufficient_stock, stock_managed_by_codesPer-field messages, keyed by the input's path in the body or query.
availableinsufficient_stockThe quantity on hand of the refused line (fields names it).
customer_idcustomer_existsThe store's customer that already has this mobile.
scopeinsufficient_scopeThe scope the key lacks.
feature, required_planfeature_lockedThe plan feature the call needs, and the cheapest plan that includes it.
itemsout_of_stockThe indexes of the order lines without enough stock.
from, toinvalid_transitionThe order's current status and the status asked for.

By HTTP status

  • 401, 402, and 403 ip_not_allowed or store_suspended: refused before the rate count, so they carry no X-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-After seconds. See Rate limits and retries.
  • 5xx: retry with growing waits and the same Idempotency-Key; 5xx answers are not kept against it.