Going further · Module 14, deep dive
API error codes
When the public API refuses a call, it says why, with a stable code. This page is the dictionary of those codes: one for your developer or integrator to keep at hand, and the link every error returns in its type field.
8 min read
Reading an error
Every error follows the RFC 9457 standard (application/problem+jsonformat): a small JSON object, always the same, whatever the route. Example of a refusal for momentary saturation:
503 response, with the Retry-After: 2 header
{ "type": "https://cocopim.fr/docs/erreurs-api#server_busy", "title": "Service indisponible", "status": 503, "detail": "Le service est momentanément saturé. Réessayez dans quelques secondes.", "code": "server_busy", "instance": "/api/v1/products" }
- code: the stable identifier of the error, the only field your program should compare. It does not change from one version to the next.
- status: the HTTP status, repeated in the body.
- detail: a sentence for a human, in French. It can be reworded at any time: never compare it.
- type: a link to the explanation of the code, on this page.
- instance: the path called; errors (on a validation): the list of rejected fields, each with its own code and message.
What to do, in short
- 400 and 422: the request itself is at fault. Sending it again as is gets the same refusal: fix it.
- 401 and 403: the key, its scopes, the plan or the account. Nothing to retry, an action is needed in cocoPIM.
- 404: the resource does not exist, or not for this key (the two cases are deliberately indistinguishable).
- 409: a conflict with the state of the catalog, to resolve before retrying.
- 429 and 503: transient. Wait for the delay of the Retry-After header (in seconds) when present, otherwise a few seconds, doubling the wait after each new failure.
- 500: a problem on our side. Retry once; if it persists, write to support with the time of the call and the value of instance.
Key, scopes and account
invalid_api_key · 401
Key missing, malformed, unknown or revoked. Check the Authorization: Bearer cpk_live_… header and that the key still exists in Developers → API keys.
api_key_expired · 401
The expiry date of the key has passed. Create a new one: an expired key cannot be extended.
too_many_failed_auth · 429
Too many calls refused for an invalid key in a short time: cocoPIM blocks the source for a while. Fix the key first, then retry after a minute.
insufficient_scope · 403
The key is valid but lacks the requested scope (for instance a write with a key limited to catalog:read). Scopes are chosen when the key is created: create another one with the right scope.
PACK_FEATURE_REQUIRED · 403
The organization’s plan does not include this feature: the REST API needs the Pro plan, the GraphQL API the Growth plan. The response names the feature and the required plan.
AI_DISABLED_BY_ORGANIZATION · 403
The organization turned AI off in its settings: operations that use it are refused. Only an administrator of the organization can turn it back on.
account_read_only · 403
The account is read-only (for instance after a trial ends or an unpaid invoice): reads go through, writes are refused until the situation is settled.
organization_inactive · 403
The organization of the key is suspended or closed: the public API is no longer open to it.
Request refused
bad_request · 400
A malformed parameter: invalid pagination cursor, missing query field on GraphQL, badly written channels list. The detail names the parameter.
invalid_channel · 400
A channel of the channels parameter does not exist, or the key is not entitled to it (key limited to some channels).
validation_failed · 422
One or more fields of the body are invalid. The errors array lists every rejected field with the reason: fix them all before sending again.
missing_idempotency_key · 400
Creations require an Idempotency-Key header (letters, digits and hyphens, 255 characters at most). Generate a unique value per operation, a UUID for instance.
idempotency_key_reused · 422
This idempotency key was already used for a different body. A key must only replay exactly the same request.
idempotency_in_progress · 409
The same request, with the same key, is still being processed. Wait a few seconds and send it again: you will receive its result.
not_found · 404
The resource does not exist, or is not visible to this key. For security, both cases give the same answer.
conflict · 409
The operation contradicts the state of the catalog (a code already taken, for instance). The detail says which; read the resource again before retrying.
option_value_code_exists · 409
A value with this code already exists in the option list.
option_value_in_use · 409
The option value is an axis of existing variants: it can be neither deactivated nor deleted while they depend on it.
computed_type_not_supported · 422
Calculated fields and AI fields are created in the application, which guides their setup, not through the public API.
variant_not_updatable · 422
A variant is not edited directly through the API: edit its master product, which it inherits from.
Rate limits and quotas
rate_limited · 429
Too many calls in one minute for this key: 100 requests, including at most 20 writes. Wait for the delay of the Retry-After header, and spread large uploads (or go through the file import of the interface).
monthly_quota_exceeded · 429
The monthly quota set on this key is reached. Retry-After gives the number of seconds until the 1st of next month (UTC); to keep going before that, raise the quota of the key in cocoPIM.
rate_limit_unavailable · 503
The rate counter is momentarily unreachable: as a precaution, writes are refused. Retry in a few seconds.
Service availability
server_busy · 503
The service is momentarily saturated: the request was refused before any execution (at once, or after a short wait for a database connection), nothing was changed. Retry after the delay of the Retry-After header (2 seconds).
query_timeout · 503
The request exceeded the maximum time allowed and was stopped: a write is canceled as a whole, nothing is saved halfway. Retry after the delay of the Retry-After header (5 seconds); if it still fails, make it lighter (smaller page, more precise filter).
MAINTENANCE_MODE_ACTIVE · 503
cocoPIM is under scheduled maintenance. The detail gives the notice; retry at the end of the announced window.
openapi_not_ready · 503
The OpenAPI specification is built when the service starts. Retry in a few seconds.
internal_error · 500
An unexpected error on our side (the message stays deliberately generic). Retry once; if it happens again, write to support with the time of the call and the value of instance.
GraphQL
A GraphQL request refused before its execution (syntax, size, key, quota) answers with an HTTP error status and the same object as REST. An error raised during execution answers 200 with an errors array: its code is in errors[].extensions.code, with the same values as on this page.
graphql_syntax_error · 400
The GraphQL document cannot be read: syntax error.
graphql_max_depth_exceeded · 400
More than 10 levels of nesting. Split the request or use fragments.
graphql_max_complexity_exceeded · 400
Complexity budget exceeded (1,000 points). Ask for fewer fields or smaller pages.
graphql_document_too_complex · 400
The document is too costly to analyze. Simplify it.
graphql_too_many_fragments · 400
More than 30 fragment definitions in a single document.
graphql_batching_not_supported · 400
One operation per request, and one root field per mutation. Send them one at a time.
graphql_execution_timeout · 504
Execution took more than 5 seconds. Reduce the request (fewer fields, smaller pages) before sending it again.
The rest of the API (keys, scopes, limits, webhooks) is presented in the API & webhooks module.