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. A test key starts test checkouts. Send an Idempotency-Key: a retry with it answers the same session, as it is now.
Body
application/json3 required, 6 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 11 to 1,000buyer_emailstring requiredWhere anyshop delivers the orderUp to 254 characterscouponstring A coupon code of the storeUp to 64 characterspayment_methodenum paypal, btc, ltc, nowpayments (live mode only) or stripe (cards; some product types may not be available on cards), as your store offers them, or simulated in test mode: it starts when the buyer opens the url. Without it the buyer chooses on the session's pagepaypalbtcltcnowpaymentsstripesimulatedUp 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.metadata
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, it is a test key where only a live key may act (the catalog), 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