ReferenceError codes
Errors
every code, and what to do.
Every error answers with a 4xx or 5xx status and the same body. Branch on the type first, then the code. The message is written for a person and can change; param names the field at fault when there is one.
The body
{
"error": {
"type": "invalid_request",
"code": "invalid_body",
"message": "quantity: Too big: expected number to be <=1000",
"param": "quantity"
}
}param is null when the error is not about one field. A price_changed error also has amount, what the checkout costs now in minor units. An error that waits, such as 429, carries a Retry-After header in seconds. New codes can appear within v1: when your code meets one it does not know, act on its type and status.
Types
| Status | type | What it means | What to do |
|---|---|---|---|
| 400, 405, 413 | invalid_request | The request is wrong | Fix it; sending it again unchanged fails again |
| 401 | authentication | No API key, or not a valid one | Check the key and that it was not revoked |
| 403 | permission | The key may not do this | See the code: a scope, a suspended store, a blocked buyer |
| 404 | not_found | Nothing at that path, or with that ID in this store | Check the ID and which store the key belongs to |
| 409 | conflict | The object's state does not allow it | Read the object again, then decide |
| 400, 409 | idempotency | An Idempotency-Key problem | See the code |
| 429 | rate_limited | Too many requests, or too much held at once | Wait for Retry-After, then try again |
| 500 | api_error | Our fault | Try again; with the same Idempotency-Key, a retry is safe |
Every code
| Status | type | code | When |
|---|---|---|---|
| 400 | invalid_request | invalid_body | A body field is missing, of the wrong type or out of range; param names it |
| 400 | invalid_request | invalid_query | A query parameter is wrong; param names it |
| 400 | invalid_request | invalid_json | The body is not JSON, or names a __proto__ key anywhere |
| 400 | invalid_request | invalid | A value breaks one of the object's rules, such as a return address off your allowed sites; the message says which |
| 400 | invalid_request | invalid_email | buyer_email or email is not an email address |
| 400 | invalid_request | invalid_coupon | A checkout session's coupon cannot be used for this purchase |
| 400 | invalid_request | invalid_payment_method | A checkout session's payment_method is not one your store offers here |
| 400 | invalid_request | invalid_price | A checkout session's price is outside the variant's bounds: below its minimum_price or above 100 times its suggested_price; the message says which |
| 400 | invalid_request | invalid_answers | A checkout session's answers leave a required question for the buyer unanswered, or give one an answer it does not take (an email that is not one, an option not listed, too long); param names the question (answers.pq_...) and the message says what is wrong |
| 400 | invalid_request | below_payment_minimum | A checkout session's total is above 0 but below the smallest payment its payment_method takes (Stripe's minimum charge in your currency, for example); the message says the amount |
| 400 | idempotency | invalid_idempotency_key | The Idempotency-Key is not 1 to 255 visible characters |
| 401 | authentication | invalid_api_key | No Authorization: Bearer key, or a key that is not valid or was revoked |
| 403 | permission | missing_scope | The key lacks the scope the endpoint needs; the message names it |
| 403 | permission | store_suspended | The store is suspended: reading and serving what it already sold still work |
| 403 | permission | forbidden | The key may not do this; the message says why |
| 403 | permission | buyer_blocked | A checkout session's buyer email is on your blocklist |
| 404 | not_found | not_found | Nothing with that ID in this store |
| 404 | not_found | no_route | No endpoint at this path |
| 405 | invalid_request | method_not_allowed | The path exists, not with this method; the Allow header lists the ones it takes |
| 409 | conflict | conflict | The object's state does not allow it, such as refunding a refunded order or cancelling a paid checkout session |
| 409 | conflict | sold_out | A checkout session asks for more than is in stock |
| 409 | conflict | price_changed | A checkout session's expected_amount is not what it costs now (a price or a quantity discount changed, or a sale started or ended); amount in the error says the new total |
| 409 | conflict | unavailable | The product or option cannot be sold now |
| 409 | conflict | no_payment_methods | Your store has no way to pay for this checkout |
| 409 | conflict | store_not_approved | anyshop has not approved your store yet: no checkout starts until it has. Products, stock and webhooks can be set up meanwhile |
| 409 | conflict | store_paused | You paused your store (Settings, General, Visibility): no new checkout starts |
| 409 | conflict | not_paid | Resending the delivery email of an order that is not paid |
| 409 | idempotency | idempotency_key_reused | The same Idempotency-Key with a different request |
| 409 | idempotency | idempotency_in_progress | A request with this Idempotency-Key is still running: try again in a moment |
| 413 | invalid_request | body_too_large | The body is over 4 MB |
| 429 | rate_limited | rate_limited | Over a limit: 1,000 requests a minute per key, failed authentication per network, or the checkout limits per key and per buyer email |
| 429 | rate_limited | too_many_open_sessions | 100 checkout sessions open at once for this store: wait for some to end, or cancel them |
| 429 | rate_limited | too_much_stock_held | Open checkout sessions already hold the share of a product's keys they may |
| 500 | api_error | internal | Something went wrong on our side |
The limits behind 429 are in Rate limits and, for checkout sessions, in Sell from your own site.
The license checks
The four public license checks (POST /v1/licenses/validate, POST /v1/licenses/activate, POST /v1/licenses/deactivate and POST /v1/licenses/offline) answer a refusal with a shorter body, { "ok": false, "error": { "code", "message" } }, so an app can branch on ok:
| Status | code | When |
|---|---|---|
| 400 | invalid_key | Not a license key |
| 400 | device_required | Activate and deactivate need a device_id |
| 403 | revoked | The seller revoked the license |
| 403 | expired | Past its expires_at |
| 404 | not_found | No license has this key, or no offline file for it |
| 404 | not_activated | The key is good, but not active on this device |
| 409 | device_limit | Active on as many devices as it allows |
| 429 | rate_limited | Too many calls from this network or for this license; see Retry-After |
A body that is not JSON, or does not fit the call's fields, is refused before the check runs, with the full body above (invalid_json, invalid_body). What your app does for each code is in Check licenses.