Guides
Errors
The error envelope
Read error.code in your code and show error.message to people. Codes never change; messages may.
{
"error": {
"code": "not_found",
"message": "Product not found."
}
}Status and codes
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_json | The body is not valid JSON, or is not a JSON object. |
| 400 | invalid_idempotency_key | The `Idempotency-Key` is empty or longer than 255 characters. |
| 401 | unauthorized | No key on an endpoint that needs one. |
| 401 | invalid_key | The key is unknown, revoked, or expired. |
| 403 | insufficient_scope | The key lacks the scope this operation needs. |
| 403 | platform_only | Only the 3Commerce shop’s own key may do this, such as issuing a gift card. |
| 404 | not_found | No such endpoint, or the resource is not in your shop. |
| 405 | method_not_allowed | The path exists with another method. See the `Allow` header. |
| 409 | invalid_status | The resource is not at a step that allows this, such as refunding a rejected return. |
| 409 | already_resolved | The refund request was already approved or declined. |
| 409 | already_exists | Something with that key exists, such as a redirect from the same path. |
| 409 | code_taken | Another shop already uses that discount code. Codes are unique across 3Commerce. |
| 409 | slug_taken | Another collection uses that URL. |
| 409 | limit_reached | The shop or the record is at its limit, such as 20 tags on a customer. |
| 409 | no_domain | The site has no custom domain to check. |
| 409 | idempotency_in_progress | A request with this `Idempotency-Key` is still running. Retry shortly. |
| 409 | conflict | The change cannot be made as things stand. `message` says why. |
| 422 | invalid_input | The input failed validation. `details` says which fields. |
| 422 | invalid_assignee | The assignee is not a team member who can reply to customers. |
| 422 | idempotency_key_reused | The `Idempotency-Key` was already used for another operation. |
| 429 | rate_limited | Too many calls this minute. Wait and retry. |
| 500 | server_error | Something broke on our side. Retry with backoff. |
| 502 | payment_provider_error | Stripe refused a refund. Nothing was recorded, so the call is safe to retry. |
| 502 | upstream_error | A service we depend on, such as domain verification, failed. Retry later. |
| 503 | unavailable | The feature is not set up on this deployment, such as custom domains. |
A record that belongs to another shop answers 404, never 403, so keys cannot probe for ids outside their shop.
Validation errors
A 422 carries details: formErrors for the input as a whole and fieldErrors keyed by field name.
{
"error": {
"code": "invalid_input",
"message": "The request did not match the schema.",
"details": {
"formErrors": [],
"fieldErrors": {
"limit": [
"Too big: expected number to be <=100"
]
}
}
}
}Retries and idempotency
Retry a 429, 500, 502, or a dropped connection with backoff. To retry a create safely, send an Idempotency-Key header: any unique string, such as a UUID. For 24 hours, a retry with the same key answers with the first result instead of creating a second record. A call that failed frees its key, so the retry runs again.
curl -X POST https://3commerce.com/api/v1/discounts \
-H "Authorization: Bearer 3c_live_…" \
-H "Idempotency-Key: 6f0c2b1e-8a4d-4f7e-9c3b-1d2e3f4a5b6c" \
-H "Content-Type: application/json" \
-d '{"code":"WELCOME10","kind":"percent","value":10}'Errors over MCP
MCP tools return the same envelope as text, with isError set on the result, so an agent can read the code and recover on its own. A create's tool takes an idempotency_key argument in place of the header.