Promotions
Create a Promotion
Storefront API
- Authentication
- Account
- Account / Address
- Account / Credit Cards
- Account / Orders
- Order Status
- Cart
- Cart / Line Items
- Cart / Other
- Cart / Coupons
- Checkout
- Checkout / State
- Checkout / Shipments
- Checkout / Payments
- Checkout / Store Credit
- Stripe
- Products
- Vendors
- Stores
- Taxons
- Countries
- CMS Pages
- Menus
- Wishlists
- Wishlists / Wished Items
- Digital Downloads
Platform API
- Authentication
- Addresses
- Adjustments
- Classifications
- CMS Pages
- CMS Sections
- Countries
- Data Feeds
- Digital Links
- Digital Assets
- Line Items
- Menu Items
- Menus
- Option Types
- Option Values
- Orders
- Payment Methods
- Payments
- Products
- Promotion Actions
- Promotion Categories
- Promotion Rules
- Promotions
- Roles
- Shipments
- Shipping Categories
- Shipping Methods
- States
- Stock Items
- Stock Locations
- Store Credit Categories
- Store Credit Types
- Store Credits
- Tax Categories
- Tax Rates
- Taxonomies
- Taxons
- Users
- Variants
- Vendors
- Webhook Events
- Webhook Subscribers
- Wished Items
- Wishlists
- Zones
Promotions
Create a Promotion
Creates a Promotion
POST
/
api
/
v2
/
platform
/
promotions
curl --request POST \
--url http://{defaultHost}/api/v2/platform/promotions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"promotion": {
"name": "Promotions Used in 2021",
"code": "BLK-FRI",
"description": "Save today with discount code XYZ at checkout.",
"usage_limit": 100,
"advertise": true,
"starts_at": "<string>",
"ends_at": "<string>",
"store_ids": [
"2"
]
}
}'
{
"data": {
"id": "35",
"type": "promotion",
"attributes": {
"description": "First 1000 Customers Save 20%",
"expires_at": "2022-11-12T19:35:03.283Z",
"starts_at": "2022-11-08T19:35:03.283Z",
"name": "Black Friday 20% Off",
"type": "Spree::Promotion",
"usage_limit": 1000,
"match_policy": "any",
"code": "BLK-20",
"advertise": true,
"path": "/black-fri/today",
"created_at": "2022-11-08T19:35:03.521Z",
"updated_at": "2022-11-08T19:35:03.533Z",
"public_metadata": {},
"private_metadata": {}
},
"relationships": {
"promotion_category": {
"data": {
"id": "15",
"type": "promotion_category"
}
},
"promotion_rules": {
"data": []
},
"promotion_actions": {
"data": []
},
"stores": {
"data": [
{
"id": "382",
"type": "store"
},
{
"id": "383",
"type": "store"
},
{
"id": "381",
"type": "store"
}
]
}
}
}
}
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Query Parameters
Select which associated resources you would like to fetch, see: <a href="https://jsonapi.org/format/#fetching-includes">https://jsonapi.org/format/#fetching-includes</a>
Body
application/json
Give the promotion a name.
Example:
"Promotions Used in 2021"
Set the promotion code. Promotions without a code are automatically applied if the order meets the Promotion Rule requirements.
Example:
"BLK-FRI"
Give the promotion a description.
Example:
"Save today with discount code XYZ at checkout."
If you wish you can set a usage limit for this promotion.
Example:
100
Set a date and time that this promotion begins.
Set a date and time that this promotion ends.
Was this page helpful?
curl --request POST \
--url http://{defaultHost}/api/v2/platform/promotions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"promotion": {
"name": "Promotions Used in 2021",
"code": "BLK-FRI",
"description": "Save today with discount code XYZ at checkout.",
"usage_limit": 100,
"advertise": true,
"starts_at": "<string>",
"ends_at": "<string>",
"store_ids": [
"2"
]
}
}'
{
"data": {
"id": "35",
"type": "promotion",
"attributes": {
"description": "First 1000 Customers Save 20%",
"expires_at": "2022-11-12T19:35:03.283Z",
"starts_at": "2022-11-08T19:35:03.283Z",
"name": "Black Friday 20% Off",
"type": "Spree::Promotion",
"usage_limit": 1000,
"match_policy": "any",
"code": "BLK-20",
"advertise": true,
"path": "/black-fri/today",
"created_at": "2022-11-08T19:35:03.521Z",
"updated_at": "2022-11-08T19:35:03.533Z",
"public_metadata": {},
"private_metadata": {}
},
"relationships": {
"promotion_category": {
"data": {
"id": "15",
"type": "promotion_category"
}
},
"promotion_rules": {
"data": []
},
"promotion_actions": {
"data": []
},
"stores": {
"data": [
{
"id": "382",
"type": "store"
},
{
"id": "383",
"type": "store"
},
{
"id": "381",
"type": "store"
}
]
}
}
}
}