Create a Cart
POSThttps://useast.api.elasticpath.com/v2/carts
Creates a cart. Call this endpoint each time a customer creates a cart.
Each shopper can have multiple carts. Use the carts API to create a cart. The carts are distinct from one another. Shoppers can add different items to their carts. They can check out one of the carts without affecting the content or status of their other carts.
After the shopper checks out the cart, the cart remains available to the shopper. The cart is persistent and stays with the shopper after it is used.
You can also create a cart to specify custom discounts. You can enable custom discounts when the discount_settings.custom_discounts_enabled
field is set to true
. Default is set from cart discount settings for the store. See Update Cart Settings.
Preview Cart
You can set a future date for your shopping cart and view the promotions that will be available during that time period. This feature enables you to validate your promotion settings and observe how they will be applied in the cart.
- Once the cart is in preview mode, you cannot revert it to a regular cart.
- Carts with
snapshot_date
are same as preview carts. - You cannot checkout a cart that includes a
snapshot_date
. - To delete a promotion preview cart, use Delete a cart endpoint.
- The promotion preview cart has the same expiration time as a regular cart based on the store's cart settings.
- Preview cart interactions skip inventory checks and events, allowing users to preview future carts without impacting related external systems.
Errors
400 Bad Request
: This is returned when the submitted request does not adhere to the expected API contract for the endpoint.- For example, in the case of string fields, this error might indicate issues in the length or format of submitted strings. For more information about valid string fields, refer to Safe Characters section.
- In the case of preview carts (those with
snapshot_date
), an error is returned for invalid actions, such as removing the preview date, setting a preview date in the past, or attempting to checkout a cart with asnapshot_date
.
Request
Header Parameters
A customer token to be associated with the cart.
- application/json
Body
The cart description.
discount_settings object
The cart name provided by the shopper. A cart name must contain 1 to 255 characters. You cannot use whitespace characters, but special characters are permitted. For more information, see the Safe Characters section.
This optional parameter sets a reference date for the cart. If this parameter is set, it allows the cart to act as one that might occur on that specified date. For example, such future carts might acquire future-enabled discounts, allowing users to test and validate future interactions with carts. The snapshot_date must be in the format 2026-02-21T15:07:25Z. By default, this parameter is left empty.
custom_attributes object
To remove the Stripe payment intent from a cart, pass the empty value in the payment_intent_id
field. You must use an empty value for this field. You cannot use this endpoint to directly update the cart to use an existing Payment Intent.
Responses
- 200
- 401
Response Headers
- application/json
- Schema
- Example (from schema)
Schema
data object
{
"data": {
"id": "string",
"type": "string",
"name": "string",
"description": "string",
"discount_settings": {
"custom_discounts_enabled": true,
"use_rule_promotions": true
},
"payment_intent_id": "string",
"links": {
"self": "string"
},
"meta": {
"display_price": {
"with_tax": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"without_tax": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"tax": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"discount": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"without_discount": {
"amount": 0,
"currency": "string",
"formatted": "string"
},
"shipping": {
"amount": 0,
"currency": "string",
"formatted": "string"
}
},
"timestamps": {
"created_at": "string"
}
},
"relationships": {
"customers": {
"data": {
"type": "string",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
},
"items": {
"data": {
"type": "string",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
}
}
}
}
Unauthorized
- application/json
- Schema
- Example (from schema)
- Example
Schema
[
null
]
{
"errors": {
"status": 401,
"title": "Unauthorized"
}
}
Authorization: http
name: bearerAuthtype: httpscheme: bearer
- curl
- python
- go
- nodejs
- ruby
- csharp
- php
- java
- powershell
- CURL
curl -L -X POST 'https://useast.api.elasticpath.com/v2/carts' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <TOKEN>' \
--data-raw '{
"description": "string",
"discount_settings": {
"custom_discounts_enabled": true,
"use_rule_promotions": true
},
"name": "string",
"snapshot_date": "string",
"custom_attributes": {
"custom_attributes": {
"attribute": {
"type": "string",
"value": "string"
}
}
},
"payment_intent_id": "string"
}'