# API reference v1

Products, stock, coupons, orders, customers, checkout sessions, licenses, webhooks and events, and data exports of your store, as JSON over HTTPS at api.anyshop.io. Every endpoint follows the rules on this page; its own page lists only what is its own. The same reference, as an OpenAPI 3.1 document, is at /v1/openapi.json.

## What it covers

| Resource | What you do with it |
| --- | --- |
| Products and stock | Create, change, publish and unpublish products; add, list and reveal keys |
| Coupons | Create, list, change and archive codes buyers type at checkout |
| Orders | List and read orders, refund them, take back what was delivered, resend the delivery email |
| Customers | List and read your buyers, keep a record by email, record marketing consent |
| Checkout sessions | Start a checkout for a buyer on your own site, with the answers to your questions for the buyer, read it, cancel it |
| Licenses and license checks | Look up, revoke and free devices from your server; check keys from your app |
| Webhooks and events | Manage endpoints and their secrets; list the events of the last 30 days |
| Exports | Export your store's data as files |

Erasing a customer and exporting one customer's data are not in the API: they stay in the dashboard, with the owner's fresh two-factor code when two-factor is on. What changed and what stays stable is in the [changelog](https://docs.anyshop.io/changelog.md).

## Authentication

Send an API key from the dashboard's Developers, API keys as a Bearer token. Every key is a live key, `as_live_...`, and belongs to one store: nothing in a request can reach another store. Keep keys on your servers, never in a browser or an app.

You can make a key on your store's first day. Before anyshop approves your store, the key can set up products, stock, coupons and webhooks, and a checkout answers `store_not_approved` (409). Objects keep their `livemode` field, always `true`, because v1 does not remove fields.

curl:

```bash
curl https://api.anyshop.io/v1/orders?limit=10 \
  -H "Authorization: Bearer $ANYSHOP_API_KEY"
```

Each key has scopes, such as `orders:read` or `products:write`; a write scope includes reading. Full stock keys come back only from `POST /v1/stock_items/{id}/reveal`, which needs `stock:reveal` and is recorded in your security log. The license checks, the index and the OpenAPI document need no key.

Browsers: the four license checks answer web pages on any site (`Access-Control-Allow-Origin: *`, without credentials, for a JSON body), so an app can check a license from the page; see [Check licenses](https://docs.anyshop.io/guides/licenses.md#from-a-web-page). No other endpoint answers a page on another site, so an API key never belongs in a browser.

## Errors

Every error answers with a 4xx or 5xx status and the same body. Branch on `type` and `code`; `message` is for a person, and `param` names the field at fault when there is one. Every code, and when it happens, is in [Error codes](https://docs.anyshop.io/errors.md).

400 invalid_request:

```json
{
  "error": {
    "type": "invalid_request",
    "code": "too_long",
    "message": "name is at most 120 characters",
    "param": "name"
  }
}
```

| Status | type | When |
| --- | --- | --- |
| 400 | `invalid_request` | A parameter or the body is wrong; `param` says which |
| 401 | `authentication` | No API key, or not a valid one |
| 403 | `permission` | The key lacks the scope (`missing_scope`), or the store is suspended (`store_suspended`) |
| 404 | `not_found` | Nothing with that ID in this store |
| 409 | `conflict` | The object's state does not allow it, such as refunding a refunded order |
| 409 | `idempotency` | An `Idempotency-Key` reused for another request, or still running |
| 429 | `rate_limited` | Too many requests; wait for `Retry-After` |
| 500 | `api_error` | Our fault. Try again; with an `Idempotency-Key`, a retry is safe |

## Pagination

Lists answer `{ "object": "list", "data": [...], "has_more": true }`, newest first. Ask for up to 100 with `limit` (20 by default), and for the next page pass the last ID you got as `starting_after`.

curl:

```bash
curl "https://api.anyshop.io/v1/orders?limit=100&starting_after=ord_01m3rt5x2c7q9f0a4d6k8h1n3p" \
  -H "Authorization: Bearer $ANYSHOP_API_KEY"
```

## Idempotency

Send an `Idempotency-Key` header with any write, 1 to 255 visible characters such as a UUID. For 24 hours, a retry with the same key and the same request gets the first answer again, with an `idempotent-replayed: true` header, and the work runs once. The same key with a different request is refused with `idempotency_key_reused`, and a retry while the first request is still running with `idempotency_in_progress`: try again in a moment.

## Rate limits

1,000 requests a minute per API key. Over it, the answer is `429` with a `Retry-After` header in seconds. Failed authentication is limited per network, and the public license checks have their own limits, in the [licenses guide](https://docs.anyshop.io/guides/licenses.md).

## Money and time

Amounts are integers in minor units of the store's currency: `1999` is $19.99, and `1999` in JPY is ¥1,999. Times are ISO 8601 strings in UTC, such as `2026-10-02T14:21:07.000Z`. IDs start with their object's prefix, like `prod_`, `ord_` and `lic_`.

## Prices and sales

A variant's `price` is its own price per unit, and `compare_at_price` an earlier price shown struck through beside it. Outside a sale, `compare_at_price` is yours to keep right: in the EU a price cut must compare with your lowest price of the 30 days before it.

A sale is a lower price for one variant for a set time, up to 90 days, scheduled in the dashboard's product editor (Price and options, Sales). It starts and ends by itself; one not started yet can be cancelled, and a running one ended now. A variant's sales never overlap, and a variant has at most 5 scheduled or running at once. Variants whose price the buyer chooses, and free ones, take no sale; bundles take sales like any fixed price. The editor says, under the "Was" price: "In the EU, a price cut must compare with your lowest price of the 30 days before it. During a sale, anyshop shows that price for you."

The sale price must be below the variant's lowest price of the 30 days before the sale starts (its reference): its own price over those days, and an earlier sale's price while that sale ran. While the sale runs, buyers see the reference struck through in place of `compare_at_price`, and beside the sale price on the product page and at checkout: "Lowest price in the 30 days before the sale: $59.00". A change of the variant's price that would put a scheduled or running sale at or above its reference, or the price at or below a sale's, is refused until you cancel or end that sale.

In the API, sales are read only: a variant's `current_price` is what buyers pay now, and `sale` the running sale with its `reference_price`, `starts_at` and `ends_at`; an order item priced at a sale has `sale` with its `reference_amount`. Checkout charges the sale price, with quantity discounts and then coupons on it.

## Questions for the buyer

A product can ask the buyer up to 3 questions at checkout, set in the dashboard's product editor (Checkout, Questions for the buyer): a short text (up to 200 characters), an email address, or a choice from a list of 2 to 20 options, each required or optional, with a help text under the field. Ask only what you need to deliver the order. Questions that ask for passwords, payment card details, government ID numbers or health information are refused, and the Acceptable Use Policy does not allow asking for them. A bundle asks its own questions: the products it holds ask nothing at its checkout. A free order asks them too.

The hosted checkout, the buy button's overlay and a demo store's checkout ask them after Email, under "Larkfield asks" (your store's name), and refuse Pay until every required one is answered as it should be. In the API, a product's `questions` lists them (read only), and a [checkout session](https://docs.anyshop.io/reference/create-checkout-session.md) takes the answers your own page asked in `answers`, keyed by question ID: a required question unanswered, an email that is not one, an option not listed or an answer too long starts nothing, with `400` and `invalid_answers`, `error.param` naming the question (`answers.pq_...`).

anyshop stores the answers encrypted with the order. Each order item has `answers`: `[{ "question_id", "question", "kind", "answer" }]`, the question as the buyer read it (editing a question later does not change past orders), in the questions' order, empty for none. They are in the REST API's orders, in the `order.paid` and `order.fulfilled` events, and in the request to your server for a "From your server" product, and on the order's page in the dashboard. They are never in an email, your store's data exports (orders.csv and orders.json) or the order's timeline. A buyer's own data, which you export from the dashboard (Customers, Export their data) when they ask for it, includes their answers. They are deleted with the order, and when you delete a buyer's data at their request.

## Suspended stores

While a store is suspended its keys can still read everything, and still serve what it already sold: refunds, taking back items, resending the delivery email, revealing a stock key, revoking a license and freeing its devices, managing webhook endpoints, and starting a data export. Its webhooks keep delivering. Anything that sells or changes the catalog answers `403` with `store_suspended`; each endpoint's page says which it is.

## Every endpoint

From the OpenAPI document, https://api.anyshop.io/v1/openapi.json.

### The API

- [The OpenAPI document](https://docs.anyshop.io/reference/get-open-api.md): `GET /v1/openapi.json`
- [The API index](https://docs.anyshop.io/reference/get-api.md): `GET /v1`

### Products

- [List products](https://docs.anyshop.io/reference/list-products.md): `GET /v1/products`
- [Create a product](https://docs.anyshop.io/reference/create-product.md): `POST /v1/products`
- [Retrieve a product](https://docs.anyshop.io/reference/get-product.md): `GET /v1/products/{id}`
- [Update a product](https://docs.anyshop.io/reference/update-product.md): `PATCH /v1/products/{id}`
- [Publish a product](https://docs.anyshop.io/reference/publish-product.md): `POST /v1/products/{id}/publish`
- [Unpublish a product](https://docs.anyshop.io/reference/unpublish-product.md): `POST /v1/products/{id}/unpublish`

### Stock

- [Stock counts](https://docs.anyshop.io/reference/get-stock.md): `GET /v1/products/{id}/stock`
- [List stock keys](https://docs.anyshop.io/reference/list-stock-items.md): `GET /v1/products/{id}/stock_items`
- [Add stock keys](https://docs.anyshop.io/reference/add-stock-items.md): `POST /v1/products/{id}/stock_items`
- [Revoke a stock key](https://docs.anyshop.io/reference/revoke-stock-item.md): `DELETE /v1/stock_items/{id}`
- [Reveal a stock key](https://docs.anyshop.io/reference/reveal-stock-item.md): `POST /v1/stock_items/{id}/reveal`

### Coupons

Codes buyers type at checkout. Catalog, like products: either key reads them, only a live key changes them.

- [List coupons](https://docs.anyshop.io/reference/list-coupons.md): `GET /v1/coupons`
- [Create a coupon](https://docs.anyshop.io/reference/create-coupon.md): `POST /v1/coupons`
- [Retrieve a coupon](https://docs.anyshop.io/reference/get-coupon.md): `GET /v1/coupons/{id}`
- [Update a coupon](https://docs.anyshop.io/reference/update-coupon.md): `PATCH /v1/coupons/{id}`
- [Archive a coupon](https://docs.anyshop.io/reference/archive-coupon.md): `POST /v1/coupons/{id}/archive`

### Orders

- [List orders](https://docs.anyshop.io/reference/list-orders.md): `GET /v1/orders`
- [Retrieve an order](https://docs.anyshop.io/reference/get-order.md): `GET /v1/orders/{id}`
- [Refund an order](https://docs.anyshop.io/reference/refund-order.md): `POST /v1/orders/{id}/refund`
- [Take back delivered items](https://docs.anyshop.io/reference/take-back-order-items.md): `POST /v1/orders/{id}/take_back`
- [Get the buyer's order page link](https://docs.anyshop.io/reference/get-buyer-link.md): `GET /v1/orders/{id}/buyer_link`
- [Resend the delivery email](https://docs.anyshop.io/reference/resend-delivery-email.md): `POST /v1/orders/{id}/resend_delivery_email`

### Customers

The people who bought from the store, and its customer records with their marketing consent. Records are live mode only. Erasing a customer and exporting their data stay in the dashboard, behind the owner's fresh two-factor check.

- [List customers](https://docs.anyshop.io/reference/list-customers.md): `GET /v1/customers`
- [Create or update a customer record](https://docs.anyshop.io/reference/create-customer.md): `POST /v1/customers`
- [Retrieve a customer](https://docs.anyshop.io/reference/get-customer.md): `GET /v1/customers/{id}`
- [Update a customer](https://docs.anyshop.io/reference/update-customer.md): `PATCH /v1/customers/{id}`

### Checkout sessions

Headless checkout: your server starts the checkout, your site's buyer pays on the step it names and comes back to your success_url.

- [Start a checkout for a buyer on your site](https://docs.anyshop.io/reference/create-checkout-session.md): `POST /v1/checkout_sessions`
- [Retrieve a checkout session](https://docs.anyshop.io/reference/get-checkout-session.md): `GET /v1/checkout_sessions/{id}`
- [Cancel a checkout session](https://docs.anyshop.io/reference/cancel-checkout-session.md): `POST /v1/checkout_sessions/{id}/cancel`

### Licenses

- [List licenses](https://docs.anyshop.io/reference/list-licenses.md): `GET /v1/licenses`
- [Retrieve a license](https://docs.anyshop.io/reference/get-license.md): `GET /v1/licenses/{id}`
- [Revoke a license](https://docs.anyshop.io/reference/revoke-license.md): `POST /v1/licenses/{id}/revoke`
- [Free a device](https://docs.anyshop.io/reference/free-license-device.md): `DELETE /v1/licenses/{id}/activations/{activation}`

### License checks

Called by a seller's app, with the license key

- [Validate a license](https://docs.anyshop.io/reference/validate-license.md): `POST /v1/licenses/validate`
- [Activate a license](https://docs.anyshop.io/reference/activate-license.md): `POST /v1/licenses/activate`
- [Deactivate a license](https://docs.anyshop.io/reference/deactivate-license.md): `POST /v1/licenses/deactivate`
- [Get an offline license file](https://docs.anyshop.io/reference/offline-license-file.md): `POST /v1/licenses/offline`

### Webhooks and events

- [List webhook endpoints](https://docs.anyshop.io/reference/list-webhook-endpoints.md): `GET /v1/webhook_endpoints`
- [Add a webhook endpoint](https://docs.anyshop.io/reference/create-webhook-endpoint.md): `POST /v1/webhook_endpoints`
- [Retrieve a webhook endpoint](https://docs.anyshop.io/reference/get-webhook-endpoint.md): `GET /v1/webhook_endpoints/{id}`
- [Update a webhook endpoint](https://docs.anyshop.io/reference/update-webhook-endpoint.md): `PATCH /v1/webhook_endpoints/{id}`
- [Delete a webhook endpoint](https://docs.anyshop.io/reference/delete-webhook-endpoint.md): `DELETE /v1/webhook_endpoints/{id}`
- [Rotate the signing secret](https://docs.anyshop.io/reference/rotate-webhook-secret.md): `POST /v1/webhook_endpoints/{id}/rotate_secret`
- [List events](https://docs.anyshop.io/reference/list-events.md): `GET /v1/events`
- [Retrieve an event](https://docs.anyshop.io/reference/get-event.md): `GET /v1/events/{id}`

### Exports

The store's data as a zip of JSON and CSV. Unsold keys are exported only from the dashboard.

- [Start an export](https://docs.anyshop.io/reference/create-export.md): `POST /v1/exports`
- [Retrieve an export](https://docs.anyshop.io/reference/get-export.md): `GET /v1/exports/{id}`
