Public, session based
Storefront JSON API
The storefront API runs under /shop/api by default and uses the shopper's session. Writes require application/json. Set storefront_api.enabled: false to disable these routes.
The 16 endpoints
| Method | Path | Answers |
|---|---|---|
| GET | /api/cart |
The session's cart, empty or not |
| PATCH | /api/cart |
The cart, address or shipping method set |
| DELETE | /api/cart |
204, the cart emptied |
| POST | /api/cart/items |
201 and the cart, a line added |
| PATCH | /api/cart/items/{id} |
The cart, quantity changed; 0 removes the line |
| DELETE | /api/cart/items/{id} |
The cart, a line removed |
| POST | /api/cart/coupons |
The cart, a code applied |
| DELETE | /api/cart/coupons/{code} |
The cart, a code taken off |
| DELETE | /api/cart/payment |
The cart, an open payment page cancelled |
| POST | /api/cart/bundles |
The cart, a bundle's parts swapped for the bundle |
| DELETE | /api/cart/bundles/{variant_id} |
The cart, that bundle no longer offered |
| GET | /api/shipping |
The zone and the methods on offer, or 422 |
| GET | /api/payment-methods |
The gateways and methods this cart may use |
| POST | /api/checkout |
Order placed: complete, redirect, or 422 |
| GET | /api/countries |
Every country, and which have regions |
| GET | /api/countries/{code}/regions |
The states or provinces of one |
One error object
{
"error": {
"status": 422,
"code": "validation",
"title": "Validation failed",
"detail": "The line could not be added.",
"fields": { "qty": "must be a whole number of at least 1" }
}
}
Errors return a stable code, a readable detail and any field errors. A 422 response covers issues the shopper can resolve, such as invalid input or a missing shipping address.