API referenceCheckout sessions
Start a checkout for a buyer on your site
POST methodhttps://api.anyshop.io/v1/checkout_sessions
Holds the keys for the buyer: send the buyer to the answer's url, where the buyer's browser starts the payment once anyshop has checked the buyer's own request (a GET of the url alone changes nothing). The amount comes from your prices, the quantity and the coupon; the API takes no price. success_url and cancel_url must be on your store's allowed sites. Send terms_accepted (and immediate_delivery_requested when agreement.text asks for it) only when the buyer ticked the box with those words above your own Pay button: once your store's owner has agreed to the Terms of Service of 14 November 2026, anyshop's page then does not ask again. Send an Idempotency-Key: a retry with it answers the same session, as it is now.
Body
application/json3 required, 11 optionalvariantstring The product option to sell (a variant ID); the product's own when it has oneUp to 80 charactersproductstring A product with a single optionUp to 80 charactersquantityinteger Default: the product's min_quantity_per_order (1 unless you set one). Between its min_quantity_per_order and max_quantity_per_order1 to 1,000priceinteger For a variant whose price the buyer chooses (price_kind chosen), required: what they chose to pay per unit, in minor units, from its minimum_price up to 100 times its suggested_price. 0 for a free one: the order is paid at once. Ignored for a fixed price: the variant's price is the priceAt least 0buyer_emailstring requiredWhere anyshop delivers the orderUp to 254 characterscouponstring A coupon code of the storeUp to 64 characterspayment_methodenum stripe (Stripe's own page, with every way to pay you turned on in Stripe), paypal, btc or ltc, as your store offers them: it starts when the buyer opens the url. Without it, Stripe starts when it is your store's first way to pay; otherwise the buyer chooses on the session's pagestripepaypalbtcltcUp to 20 characterssuccess_urlstring requiredWhere the buyer goes once paid, with ?checkout={id} added: https, on one of your store's allowed sites (or your store's own anyshop address)Up to 2,000 characterscancel_urlstring requiredWhere the buyer goes if they cancel: https, on one of your allowed sitesUp to 2,000 charactersmetadataobject Up to 20 keys (letters, digits, _ . or -, not starting with __), string values; echoed in the order's webhook events as checkout_session.metadataterms_acceptedboolean true only when the buyer ticked the unticked box above your own Pay button, with the words of agreement.text and "terms of sale" linking to agreement.terms_url and your refund policy. Taken once your store's owner has agreed to the Terms of Service of 14 November 2026; otherwise ignored, and anyshop's page asks the buyerimmediate_delivery_requestedboolean true only when that box's words asked for the order right away ("and want my key right away": a product with immediate_delivery_consent on) and the buyer ticked it. Without it, anyshop's page asks the buyer the whole boxexpected_amountinteger The total your page showed the buyer, in minor units. When the price computed now differs (a price or a quantity discount changed since), no session starts: 409 price_changed, with the new total in error.amountAt least 0answersobject The buyer's answers to the product's questions (the product's questions), keyed by question ID, as your page asked them: trimmed; a short text up to 200 characters, an email a valid address up to 254, a choice exactly one of its choices. Required questions must be answered: otherwise no session starts (400 invalid_answers, error.param answers.{question ID}). Stored encrypted with the order, and returned on the order's items and in its webhook events, never in emails
Headers
Idempotency-Keystring Up to 255 characters. A retry with the same key and request gets the first answer, without running twice (24 hours).
Returns
The checkout_session object.
Errors
Status and error.type400invalid_requestThe request is not valid;error.paramnames the field401authenticationNo API key, or it is not valid403permissionThe key does not have the scope this needs, or the store is suspended (store_suspended)404not_foundNot found in the key's store and mode409conflictConflicts with the object's state (type conflict), or an Idempotency-Key reused for another request (type idempotency, code idempotency_key_reused)429rate_limitedToo many requests; see Retry-After