anyshop docs homeStatusOpen the dashboard

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.

  • Branch on type, then code
  • New codes can appear within v1
  • Retry only what says so

The body

400 invalid_request
{
  "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

StatustypeWhat it meansWhat to do
400, 405, 413invalid_requestThe request is wrongFix it; sending it again unchanged fails again
401authenticationNo API key, or not a valid oneCheck the key and that it was not revoked
403permissionThe key may not do thisSee the code: a scope, a suspended store, a blocked buyer
404not_foundNothing at that path, or with that ID in this storeCheck the ID and which store the key belongs to
409conflictThe object's state does not allow itRead the object again, then decide
400, 409idempotencyAn Idempotency-Key problemSee the code
429rate_limitedToo many requests, or too much held at onceWait for Retry-After, then try again
500api_errorOur faultTry again; with the same Idempotency-Key, a retry is safe

Every code

StatustypecodeWhen
400invalid_requestinvalid_bodyA body field is missing, of the wrong type or out of range; param names it
400invalid_requestinvalid_queryA query parameter is wrong; param names it
400invalid_requestinvalid_jsonThe body is not JSON, or names a __proto__ key anywhere
400invalid_requestinvalidA value breaks one of the object's rules, such as a return address off your allowed sites; the message says which
400invalid_requestinvalid_emailbuyer_email or email is not an email address
400invalid_requestinvalid_couponA checkout session's coupon cannot be used for this purchase
400invalid_requestinvalid_payment_methodA checkout session's payment_method is not one your store offers here
400invalid_requestinvalid_priceA 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
400invalid_requestinvalid_answersA 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
400invalid_requestbelow_payment_minimumA 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
400idempotencyinvalid_idempotency_keyThe Idempotency-Key is not 1 to 255 visible characters
401authenticationinvalid_api_keyNo Authorization: Bearer key, or a key that is not valid or was revoked
403permissionmissing_scopeThe key lacks the scope the endpoint needs; the message names it
403permissionstore_suspendedThe store is suspended: reading and serving what it already sold still work
403permissionforbiddenThe key may not do this; the message says why
403permissionbuyer_blockedA checkout session's buyer email is on your blocklist
404not_foundnot_foundNothing with that ID in this store
404not_foundno_routeNo endpoint at this path
405invalid_requestmethod_not_allowedThe path exists, not with this method; the Allow header lists the ones it takes
409conflictconflictThe object's state does not allow it, such as refunding a refunded order or cancelling a paid checkout session
409conflictsold_outA checkout session asks for more than is in stock
409conflictprice_changedA 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
409conflictunavailableThe product or option cannot be sold now
409conflictno_payment_methodsYour store has no way to pay for this checkout
409conflictstore_not_approvedanyshop has not approved your store yet: no checkout starts until it has. Products, stock and webhooks can be set up meanwhile
409conflictstore_pausedYou paused your store (Settings, General, Visibility): no new checkout starts
409conflictnot_paidResending the delivery email of an order that is not paid
409idempotencyidempotency_key_reusedThe same Idempotency-Key with a different request
409idempotencyidempotency_in_progressA request with this Idempotency-Key is still running: try again in a moment
413invalid_requestbody_too_largeThe body is over 4 MB
429rate_limitedrate_limitedOver a limit: 1,000 requests a minute per key, failed authentication per network, or the checkout limits per key and per buyer email
429rate_limitedtoo_many_open_sessions100 checkout sessions open at once for this store: wait for some to end, or cancel them
429rate_limitedtoo_much_stock_heldOpen checkout sessions already hold the share of a product's keys they may
500api_errorinternalSomething 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:

StatuscodeWhen
400invalid_keyNot a license key
400device_requiredActivate and deactivate need a device_id
403revokedThe seller revoked the license
403expiredPast its expires_at
404not_foundNo license has this key, or no offline file for it
404not_activatedThe key is good, but not active on this device
409device_limitActive on as many devices as it allows
429rate_limitedToo 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.