Spree Storefront API
Legacy storefront REST API for customer-facing operations including products, cart, checkout, and account management. OpenAPI 3.0 documented.
Legacy storefront REST API for customer-facing operations including products, cart, checkout, and account management. OpenAPI 3.0 documented.
openapi: 3.0.3
servers:
- url: "https://demo.spreecommerce.org"
description: demo
- url: "http://localhost:3000"
description: localhost
info:
version: 2.0.0
title: Storefront API
description: |-
Storefront API is a modern REST API based on the [JSON API spec](https://jsonapi.org/) which provides you with all the necessary endpoints to build amazing user interfaces either in JavaScript frameworks or native mobile libraries.
Import to [Postman](https://raw.githubusercontent.com/spree/spree/main/docs/api-reference/storefront.yaml)
contact:
name: Vendo Connect Inc.
url: "https://spreecommerce.org"
email: [email protected]
license:
name: BSD-3-Clause
url: "https://github.com/spree/spree/blob/main/LICENSE.md"
paths:
/api/v2/storefront/account:
get:
description: Returns the current user details.
summary: Retrieve an Account
tags:
- Account
operationId: account-information
parameters:
- $ref: "#/components/parameters/AccountIncludeParam"
- $ref: "#/components/parameters/SparseFieldsUser"
responses:
"200":
$ref: "#/components/responses/User"
"403":
$ref: "#/components/responses/403Forbidden"
security:
- bearerAuth: []
post:
description: "Creates a new account"
summary: Create an Account
tags:
- Account
operationId: account-creation
requestBody:
required: true
content:
application/vnd.api+json:
schema:
type: object
properties:
user:
type: object
properties:
email:
type: string
example: [email protected]
first_name:
type: string
example: John
last_name:
type: string
example: Snow
selected_locale:
type: string
example: "en"
password:
type: string
example: spree123
password_confirmation:
type: string
example: spree123
public_metadata:
type: object
example:
user_segment: supplier
description: The public metadata for this User
private_metadata:
type: object
example:
has_abandoned_cart: false
description: The private metadata for this User
description: ""
responses:
"200":
$ref: "#/components/responses/User"
"422":
$ref: "#/components/responses/422UnprocessableEntity"
patch:
description: "Updates the users account details"
summary: Update an Account
tags:
- Account
operationId: account-updates
requestBody:
required: true
content:
application/vnd.api+json:
schema:
type: object
properties:
user:
type: object
properties:
email:
type: string
example: [email protected]
first_name:
type: string
example: John
last_name:
type: string
example: Snow
selected_locale:
type: string
example: "fr"
bill_address_id:
type: string
example: "1"
ship_address_id:
type: string
example: "1"
password:
type: string
example: spree123
password_confirmation:
type: string
example: spree123
responses:
"200":
$ref: "#/components/responses/User"
"422":
$ref: "#/components/responses/422UnprocessableEntity"
security:
- bearerAuth: []
/api/v2/storefront/account/addresses:
get:
description: Returns a list of addresses for the current user.
summary: List all Addresses
operationId: addresses-list
responses:
"200":
$ref: "#/components/responses/AddressList"
"403":
$ref: "#/components/responses/403Forbidden"
security:
- bearerAuth: []
parameters:
- $ref: "#/components/parameters/SparseFieldsAddress"
- in: query
name: "filter[exclude_quick_checkout]"
schema:
type: boolean
example: true
description: "Exclude addresses that were created during quick checkout"
tags:
- Account / Address
post:
description: Creates a new address for the current user.
summary: Create an Address
tags:
- Account / Address
operationId: create-address
requestBody:
required: true
content:
application/vnd.api+json:
schema:
type: object
properties:
address:
$ref: "#/components/schemas/AddressPayload"
examples:
Create an Address:
value:
address:
firstname: Mark
lastname: Winterburn
company: Paper Street Soap Co.
address1: 775 Old Georgetown Road
address2: 3rd Floor
city: Qethesda
phone: "3488545445002"
zipcode: "90210"
state_name: CA
country_iso: US
label: Work
responses:
"200":
$ref: "#/components/responses/Address"
"403":
$ref: "#/components/responses/403Forbidden"
security:
- bearerAuth: []
parameters:
- $ref: "#/components/parameters/SparseFieldsAddress"
"/api/v2/storefront/account/addresses/{id}":
delete:
description: This endpoint removes the specified address for the current user. It uses a soft delete to retain address information for pre-existing orders.
operationId: remove-address
responses:
"204":
description: 204 Success No Content Returned - Requested Address has been removed from the User Account
"404":
$ref: "#/components/responses/404NotFound"
security:
- bearerAuth: []
summary: Remove an Address
tags:
- Account / Address
patch:
description: Updates the specified address for the current user.
summary: Update an Address
operationId: update-address
parameters:
- $ref: "#/components/parameters/SparseFieldsAddress"
requestBody:
required: true
content:
application/vnd.api+json:
schema:
type: object
properties:
address:
$ref: "#/components/schemas/AddressPayload"
examples:
Update an Address:
value:
address:
firstname: Stephen
lastname: Smith
company: Woodbank School
address1: 234 Old Georgetown Road
address2: 1st Floor
city: Aethesda
phone: "34885493845002"
zipcode: "90211"
state_name: CA
country_iso: US
label: Office
responses:
"200":
$ref: "#/components/responses/Address"
"403":
$ref: "#/components/responses/403Forbidden"
security:
- bearerAuth: []
tags:
- Account / Address
parameters:
- schema:
type: string
example: "1"
name: id
in: path
required: true
description: The ID of the specified `address`.
/api/v2/storefront/account/credit_cards:
get:
description: Returns a list of credit cards for the current user.
summary: List all Credit Cards
operationId: credit-cards-list
responses:
"200":
$ref: "#/components/responses/CreditCardList"
"403":
$ref: "#/components/responses/403Forbidden"
security:
- bearerAuth: []
parameters:
- in: query
name: "filter[payment_method_id]"
schema:
type: string
example: "2"
description: Filter based on payment method ID
- $ref: "#/components/parameters/CreditCardIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCreditCard"
tags:
- Account / Credit Cards
"/api/v2/storefront/account/credit_cards/{id}":
delete:
description: Removes a specified credit card for the current user with a soft delete to retain payment information for any pre-existing orders.
operationId: remove-credit-card
responses:
"204":
description: 204 Success No Content Returned - Requested Credit Card has been removed from the User Account
"404":
$ref: "#/components/responses/404NotFound"
security:
- bearerAuth: []
summary: Remove a Credit Card
tags:
- Account / Credit Cards
parameters:
- schema:
type: string
example: "1"
name: id
in: path
required: true
description: The ID of the `credit_card` you wish to remove.
/api/v2/storefront/account/credit_cards/default:
get:
description: Returns the current user's default credit card.
summary: Retrieve the default Credit Card
operationId: default-credit-card
responses:
"200":
$ref: "#/components/responses/CreditCard"
"403":
$ref: "#/components/responses/403Forbidden"
parameters:
- $ref: "#/components/parameters/CreditCardIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCreditCard"
security:
- bearerAuth: []
tags:
- Account / Credit Cards
/api/v2/storefront/account/orders:
get:
description: Returns all completed orders placed by the current user in the current store.
summary: List all Orders
operationId: completed-orders
responses:
"200":
$ref: "#/components/responses/CartList"
"403":
$ref: "#/components/responses/403Forbidden"
parameters:
- $ref: "#/components/parameters/CartIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCart"
- $ref: "#/components/parameters/PageParam"
- $ref: "#/components/parameters/PerPageParam"
security:
- bearerAuth: []
tags:
- Account / Orders
"/api/v2/storefront/account/orders/{order_number}":
get:
description: Returns a completed order for the current user within the scope of the current store.
summary: Retrieve an Order
operationId: completed-user-order
responses:
"200":
$ref: "#/components/responses/Cart"
"403":
$ref: "#/components/responses/403Forbidden"
parameters:
- $ref: "#/components/parameters/OrderParam"
- $ref: "#/components/parameters/CartIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCart"
security:
- bearerAuth: []
tags:
- Account / Orders
parameters:
- $ref: "#/components/parameters/OrderParam"
"/api/v2/storefront/order_status/{order_number}":
get:
description: |-
Returns completed order information.
This endpoint is useful when fetching orders placed by a guest user, allowing customers without an account to check the status of their order: (shipment/payment/processing) etc.
Pass the cart `token` value as the `X-Spree-Order-Token` for authorization, and the corresponding cart `number` in the URI **{order_number}** to successfully retrieve an order.
summary: Retrieve an Order Status
operationId: order-status
responses:
"200":
$ref: "#/components/responses/Cart"
"404":
$ref: "#/components/responses/404NotFound"
parameters:
- $ref: "#/components/parameters/CartIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCart"
security:
- orderToken: []
tags:
- Order Status
parameters:
- $ref: "#/components/parameters/OrderParam"
/api/v2/storefront/cart:
post:
description: |-
Creates a new cart.
**Please be aware**; The `token` value found in the response body is used to authorize all future operations on this cart through the Auth API Key `X-Spree-Order-Token`.
tags:
- Cart
operationId: create-cart
responses:
"201":
$ref: "#/components/responses/Cart"
parameters:
- $ref: "#/components/parameters/CartIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCart"
requestBody:
required: false
content:
application/vnd.api+json:
schema:
type: object
example:
public_metadata:
total_weight: 3250
private_metadata:
had_same_cart_items: true
properties:
public_metadata:
type: object
description: The public metadata for the cart.
private_metadata:
type: object
description: The private metadata for the cart.
summary: Create a Cart
delete:
description: |-
Deletes a specified cart.
When this endpoint is successfully executed, all shipments are cancelled, payments are voided, then line items, shipments & payments are all deleted.
tags:
- Cart
operationId: deletes-cart
responses:
"204":
description: 204 Success No Content Returned - Current Cart has been removed.
"404":
$ref: "#/components/responses/404NotFound"
security:
- orderToken: []
- bearerAuth: []
summary: Delete a Cart
get:
description: Returns the cart for the current user.
tags:
- Cart
operationId: get-cart
responses:
"200":
$ref: "#/components/responses/Cart"
"404":
$ref: "#/components/responses/404NotFound"
security:
- orderToken: []
- bearerAuth: []
parameters:
- $ref: "#/components/parameters/CartIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCart"
- $ref: "#/components/parameters/CartCurrencyParam"
summary: Retrieve a Cart
/api/v2/storefront/cart/add_item:
post:
description: Adds a variant to the current cart by creating a line item. Each line item represents a specified variant and the desired quantity.
operationId: add-item
responses:
"200":
$ref: "#/components/responses/Cart"
"404":
$ref: "#/components/responses/404NotFound"
security:
- orderToken: []
- bearerAuth: []
parameters:
- $ref: "#/components/parameters/CartIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCart"
requestBody:
required: true
content:
application/vnd.api+json:
schema:
type: object
example:
variant_id: "1"
quantity: 5
public_metadata:
first_item_order: true
private_metadata:
recommended_by_us: false
properties:
variant_id:
type: string
quantity:
type: integer
public_metadata:
type: object
description: The public metadata for the added item.
private_metadata:
type: object
description: The private metadata for the added item.
options:
type: object
description: "Additional custom options. Activate these by adding: `Spree::PermittedAttributes.line_item_attributes << :foo` in `config/initializers/spree.rb`"
description: |-
Additional parameters can be passed in the **options** hash. Each custom parameter must be registered in `config/initializers/spree.rb`, eg.
```ruby
Spree::PermittedAttributes.line_item_attributes << :foo
```
summary: Add an Item to Cart
tags:
- Cart / Line Items
/api/v2/storefront/cart/set_quantity:
patch:
description: Sets the quantity of a specified line item.
operationId: set-quantity
responses:
"200":
$ref: "#/components/responses/Cart"
"422":
$ref: "#/components/responses/422UnprocessableEntity"
security:
- orderToken: []
- bearerAuth: []
parameters:
- $ref: "#/components/parameters/CartIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCart"
requestBody:
required: true
content:
application/vnd.api+json:
schema:
type: object
properties:
line_item_id:
type: string
quantity:
type: integer
example:
line_item_id: "1"
quantity: 5
description: The quantity has to be a positive integer greater than 0.
summary: Set Line Item Quantity
tags:
- Cart / Line Items
"/api/v2/storefront/cart/remove_line_item/{id}":
delete:
description: |-
Removes a line item from the cart by deleting the line item.
After deleting the line item, the system will re-calculate taxes, promotions, shipments etc.
operationId: remove-line-item
parameters:
- $ref: "#/components/parameters/CartIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCart"
responses:
"200":
$ref: "#/components/responses/Cart"
"404":
$ref: "#/components/responses/404NotFound"
security:
- orderToken: []
- bearerAuth: []
summary: Remove a Line Item
tags:
- Cart / Line Items
parameters:
- schema:
type: string
example: "1"
name: id
in: path
required: true
description: The ID of the `line_item` you wish to remove.
/api/v2/storefront/cart/empty:
patch:
description: This endpoint removed all line items from the cart. Inventory that was previously taken by this order will be re-stocked.
operationId: empty-cart
responses:
"200":
$ref: "#/components/responses/Cart"
"404":
$ref: "#/components/responses/404NotFound"
security:
- orderToken: []
- bearerAuth: []
parameters:
- $ref: "#/components/parameters/CartIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCart"
summary: Empty the Cart
tags:
- Cart / Other
/api/v2/storefront/cart/apply_coupon_code:
patch:
description: Applies a coupon code or gift card code to the current cart.
operationId: apply-coupon-code
responses:
"200":
$ref: "#/components/responses/Cart"
"422":
$ref: "#/components/responses/422UnprocessableEntity"
security:
- orderToken: []
- bearerAuth: []
parameters:
- $ref: "#/components/parameters/CartIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCart"
requestBody:
required: true
content:
application/vnd.api+json:
schema:
type: object
properties:
coupon_code:
type: string
example: DISCOUNT10
summary: Apply a Coupon Code / Gift Card
tags:
- Cart / Coupons
"/api/v2/storefront/cart/remove_coupon_code/{coupon_code}":
delete:
description: Removes a specified coupon code or gift card code from the current cart.
operationId: remove-coupon-code
parameters:
- name: coupon_code
in: path
required: true
description: Specify the coupon code or gift card code for removal.
schema:
type: string
example: DISCOUNT10
- $ref: "#/components/parameters/CartIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCart"
responses:
"200":
$ref: "#/components/responses/Cart"
"422":
$ref: "#/components/responses/422UnprocessableEntity"
security:
- orderToken: []
- bearerAuth: []
summary: Remove a Coupon / Gift Card
tags:
- Cart / Coupons
/api/v2/storefront/cart/remove_coupon_code:
delete:
description: Removes all coupons that have been applied to the current cart.
operationId: remove-all-coupon-codes
parameters:
- $ref: "#/components/parameters/CartIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCart"
responses:
"200":
$ref: "#/components/responses/Cart"
"422":
$ref: "#/components/responses/422UnprocessableEntity"
security:
- orderToken: []
- bearerAuth: []
summary: Remove all Coupons
tags:
- Cart / Coupons
/api/v2/storefront/cart/estimate_shipping_rates:
get:
description: Returns a list of shipping rates for the current cart. The rates given are only estimates and can vary from the final shipping rates.
operationId: estimate-shipping-rates
parameters:
- name: country_iso
in: query
description: Pass country ISO or ISO3 symbol to get estimations for this destination. If no code is passed we'll try to use Cart shipping address country or the default Country for the current Store.
schema:
type: string
example: USA
example: USA
required: true
- $ref: "#/components/parameters/SparseFieldsShippingRate"
responses:
"200":
$ref: "#/components/responses/EstimatedShippingRates"
"404":
$ref: "#/components/responses/404NotFound"
security:
- orderToken: []
- bearerAuth: []
summary: List Estimated Shipping Rates
tags:
- Cart / Other
/api/v2/storefront/cart/associate:
patch:
description: Associates a guest cart with the currently signed in user.
operationId: associate-cart
parameters:
- name: guest_order_token
in: query
description: Token of the guest cart to be associated with user.
schema:
type: string
example: bd7SHdOAQqTsQHsjnhoWIw1633364692479
required: true
- $ref: "#/components/parameters/CartIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCart"
responses:
"200":
$ref: "#/components/responses/Cart"
"403":
$ref: "#/components/responses/403Forbidden"
"422":
$ref: "#/components/responses/422UnprocessableEntity"
security:
- bearerAuth: []
summary: Associate a Cart with a User
tags:
- Cart / Other
/api/v2/storefront/cart/change_currency:
patch:
description: Changes the cart currency and recalculates the cart values.
operationId: change-currency
parameters:
- name: new_currency
in: query
description: The currency to change the cart to.
schema:
type: string
example: USD
required: true
- $ref: "#/components/parameters/CartIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCart"
responses:
"200":
$ref: "#/components/responses/Cart"
"403":
$ref: "#/components/responses/403Forbidden"
"422":
$ref: "#/components/responses/422UnprocessableEntity"
security:
- orderToken: []
- bearerAuth: []
summary: Change Cart Currency
tags:
- Cart / Other
/api/v2/storefront/checkout:
patch:
description: The Update Checkout endpoint allows you to manage the typical stages of an e-commerce checkout system.
tags:
- Checkout
operationId: update-checkout
responses:
"200":
$ref: "#/components/responses/Cart"
"404":
$ref: "#/components/responses/404NotFound"
"422":
$ref: "#/components/responses/422UnprocessableEntity"
security:
- orderToken: []
- bearerAuth: []
parameters:
- $ref: "#/components/parameters/CartIncludeParam"
summary: Update Checkout
requestBody:
content:
application/vnd.api+json:
schema:
type: object
properties:
order:
type: object
properties:
email:
type: string
example: [email protected]
bill_address_attributes:
$ref: "#/components/schemas/AddressPayload"
ship_address_attributes:
$ref: "#/components/schemas/AddressPayload"
shipments_attributes:
type: array
items:
type: object
properties:
id:
type: string
example: "3"
description: The Shipment `id`
selected_shipping_rate_id:
type: string
example: "10"
description: The Shipping Rate `id`
required:
- id
- selected_shipping_rate_id
payments_attributes:
type: array
items:
type: object
properties:
payment_method_id:
type: string
example: "1"
description: The `id` of the Payment Method
source_attributes:
type: object
properties:
gateway_payment_profile_id:
type: string
month:
type: number
year:
type: number
cc_type:
type: string
name:
type: string
required:
- payment_method_id
- source_attributes
examples:
Add Customer Details:
value:
order:
email: [email protected]
bill_address_attributes:
firstname: John
lastname: Snow
address1: 7735 Old Georgetown Road
city: Bethesda
phone: "3014445002"
zipcode: "20814"
state_name: MD
country_iso: US
ship_address_attributes:
firstname: John
lastname: Snow
address1: 7735 Old Georgetown Road
city: Bethesda
phone: "3014445002"
zipcode: "20814"
state_name: MD
country_iso: US
Add Shipping Rates:
value:
order:
shipments_attributes:
- id: "1"
selected_shipping_rate_id: "1"
Add a Payment:
value:
order:
payments_attributes:
- payment_method_id: "1"
source_attributes:
gateway_payment_profile_id: ABC123
cc_type: visa
last_digits: "1111"
month: 10
year: 2022
name: John Doe
description: |-
##### Add Customer Details
Adding customer details is achieved by passing the customer-related attributes shown in the corresponding request body example.
##### Add Shipping Rates
To add shipping rates, you will need a shipment associated with the checkout. If you do not have any shipments follow the steps below:
1. First, ensure your cart has items added via the **Add an Item to Cart** endpoint.
2. Next, ensure the checkout has a shipping address set, you can set this by running the *Add Customer Details* example above.
3. Next run the **Advance Checkout** endpoint, this will create shipments for the items in the cart and users shipping destination.
Use the **List Shipping Rates** endpoint to find the shipments and shipping rates available for this checkout. Note the shipment `id` and shipping_rate `id`; use these values to populate your request body.
##### Add a Payment
To add a payment method, you must find the available payment methods by running the **List Payment Methods** endpoint, each payment method has its own set of source attribute requirements. In the example shown, we have used the source attributes for a card payment.
Pass the `payment_method_id` and `source_attribute` hash containing the required attributes for the selected payment method.
/api/v2/storefront/checkout/next:
patch:
description: Goes to the next checkout step.
operationId: checkout-next
responses:
"200":
$ref: "#/components/responses/Cart"
"404":
$ref: "#/components/responses/404NotFound"
"422":
$ref: "#/components/responses/422UnprocessableEntity"
security:
- orderToken: []
- bearerAuth: []
parameters:
- $ref: "#/components/parameters/CartIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCart"
summary: Next Checkout Step
tags:
- Checkout / State
/api/v2/storefront/checkout/advance:
patch:
description: "Advances the checkout to the furthest checkout step validation allows, up until the **completed** step."
operationId: advance-checkout
responses:
"200":
$ref: "#/components/responses/Cart"
"404":
$ref: "#/components/responses/404NotFound"
"422":
$ref: "#/components/responses/422UnprocessableEntity"
security:
- orderToken: []
- bearerAuth: []
parameters:
- $ref: "#/components/parameters/CartIncludeParam"
- $ref: "#/components/parameters/SparseFieldsCart"
summary: Advance Checkout
tags:
- Checkout / State
/api/v2/storefront/checkout/complete:
patch:
description: |-
Completes the checkout by marking the order as complete.
**Please be aware**; Once a checkout is marked as `complete` it is considered a completed order, the Cart and Checkout endpoints will no longer access a completed order, and a new cart will need to be created.
If you want to access a completed order you will need to use the **Account / Orders** or **Order Status** endpoints.
operationId: complete-checkout
responses:
# --- truncated at 32 KB (604 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/spree/refs/heads/main/openapi/spree-storefront-api.yaml