Skip to content

Guides

Errors

Successful calls answer 200, or 201 when they create something. Everything else answers with 1 envelope and a stable code you can branch on.

The error envelope

Read error.code in your code and show error.message to people. Codes never change; messages may.

404 response
{
  "error": {
    "code": "not_found",
    "message": "Product not found."
  }
}

Status and codes

StatusCodeMeaning
400invalid_jsonThe body is not valid JSON, or is not a JSON object.
400invalid_idempotency_keyThe `Idempotency-Key` is empty or longer than 255 characters.
401unauthorizedNo key on an endpoint that needs one.
401invalid_keyThe key is unknown, revoked, or expired.
403insufficient_scopeThe key lacks the scope this operation needs.
403platform_onlyOnly the 3Commerce shop’s own key may do this, such as issuing a gift card.
404not_foundNo such endpoint, or the resource is not in your shop.
405method_not_allowedThe path exists with another method. See the `Allow` header.
409invalid_statusThe resource is not at a step that allows this, such as refunding a rejected return.
409already_resolvedThe refund request was already approved or declined.
409already_existsSomething with that key exists, such as a redirect from the same path.
409code_takenAnother shop already uses that discount code. Codes are unique across 3Commerce.
409slug_takenAnother collection uses that URL.
409limit_reachedThe shop or the record is at its limit, such as 20 tags on a customer.
409no_domainThe site has no custom domain to check.
409idempotency_in_progressA request with this `Idempotency-Key` is still running. Retry shortly.
409conflictThe change cannot be made as things stand. `message` says why.
422invalid_inputThe input failed validation. `details` says which fields.
422invalid_assigneeThe assignee is not a team member who can reply to customers.
422idempotency_key_reusedThe `Idempotency-Key` was already used for another operation.
429rate_limitedToo many calls this minute. Wait and retry.
500server_errorSomething broke on our side. Retry with backoff.
502payment_provider_errorStripe refused a refund. Nothing was recorded, so the call is safe to retry.
502upstream_errorA service we depend on, such as domain verification, failed. Retry later.
503unavailableThe 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.

422 response
{
  "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.

A safe retry
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.