Errors
Every error has the same JSON shape, a stable code and a matching HTTP status.
{
"code": "VALIDATION_ERROR",
"message": "ورودی معتبر نیست.",
"details": {
"products.0.id": ["The products.0.id field is required."]
}
}| Field | |
|---|---|
code | Stable and in English. Branch on this. |
message | For people, in Persian. It may change; show it, do not parse it. |
details | Only on VALIDATION_ERROR: the messages for each invalid field, by path. |
Codes
| Status | Code | What to do |
|---|---|---|
401 | UNAUTHENTICATED | The key is missing, malformed, revoked, expired or replaced. Check which key the endpoint needs. |
402 | INSUFFICIENT_CREDITS | Not enough credits for this reply. Top up or wait for the next period. |
403 | PLAN_RESTRICTED | Your plan does not include this (for example a model or a feature). |
403 | FORBIDDEN | The key is valid but may not do this. |
404 | NOT_FOUND | No such item, or it is not yours. |
409 | CONFLICT | The request clashes with the current state: a newer sync is running, a store is not connected yet, or a chat request id is still running or was reused. |
422 | VALIDATION_ERROR | Fix the fields listed in details. |
429 | RATE_LIMITED | Too many requests, or a plan's daily limit. Wait for Retry-After seconds. |
503 | UPSTREAM_UNAVAILABLE | An AI provider is not answering. Retry later with backoff. |
New codes may be added. Treat an unknown code by its HTTP status.
Retrying
Retry 429 after Retry-After, and 5xx and network errors with exponential backoff (for example 1 s, 2 s, 4 s,
with some jitter). Do not retry other 4xx errors unchanged: they fail the same way every time.
Store sync calls are safe to repeat: sending the same product twice stores it once. Chat sends are safe to repeat
with the same clientRequestId (see Retries are safe).