Create a promotion
Creates a new promotion for a shop. Promotions apply percentage or fixed-amount
discounts via coupon codes or automatic rules.
shop_id is required in the body.
POST
/promotionsAuthorization
AuthorizationBearer token (JWT) · headerrequiredRequest body
requiredapplication/jsonshop_idintegerrequiredID of the shop (required on create)
namestringrequiredstatusstringdefault: "active"
Allowed:
activeinactivecumulativebooleanWhether this promotion can stack with others. Defaults to `true`.
default: true
discount_typestringrequiredAllowed:
fixedpercentagefree-shippingdiscountnumberrequiredDiscount value — a percentage (0–100) or a fixed amount in cents.
activation_modestringrequiredHow the promotion is activated. `code` requires a coupon code; `auto` applies automatically to eligible orders; `fulfillment` activates for a specific fulfillment method; `payment` activates for a specific payment method.
Allowed:
codeautofulfillmentpaymentcodestringCoupon code (required when `activation_mode` is `code`).
fulfillment_methodintegerFulfillment method ID (required when `activation_mode` is `fulfillment`).
payment_method_idintegerPayment method ID (required when `activation_mode` is `payment`).
usage_limitintegerMaximum total redemptions. Unlimited if omitted.
per_user_limitintegerMaximum redemptions per customer. Unlimited if omitted.
starts_atstring<date-time>expires_atstring<date-time>price_range_fromintegerMinimum order subtotal in cents for the promotion to apply.
price_range_tointegerMaximum order subtotal in cents for the promotion to apply.
product_range_fromintegerMinimum number of qualifying products required in the cart.
product_range_tointegerMaximum number of qualifying products allowed in the cart.
product_discount_group_idintegerID of the group whose products receive the discount.
product_discount_group_typestringAllowed:
AllProductsAllBundlesCollectionProductTypeVendorTagProductproduct_discount_group_filter_modestringWhich items within the discount group receive the discount.
Allowed:
allall_exceptsingle_cheapestsingle_most_expensiveall_but_cheapestall_but_most_expensivecheapest_halfmost_expensive_halfcheapest_thirdmost_expensive_thirdcheapest_fourthmost_expensive_fourthsingle_cheapest_from_count_groupsingle_most_expensive_from_count_groupcheapest_half_from_count_groupmost_expensive_half_from_count_groupcheapest_third_from_count_groupmost_expensive_third_from_count_groupcheapest_fourth_from_count_groupmost_expensive_fourth_from_count_groupproduct_count_group_idintegerGroup used to count qualifying products (for count-gated discounts).
product_count_group_typestringAllowed:
AllProductsAllBundlesCollectionProductTypeVendorTagProductprice_list_idintegerRestrict the promotion to orders using this price list.
apply_tagstringTag to apply to the order when this promotion is used.
Responses
201Promotion created
422Validation error
Request
curl -X POST "https://api.onbolder.com/v2/promotions" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"shop_id": 1,
"name": "Summer Sale",
"code": "SUMMER20",
"discount_type": "percentage",
"discount": 20,
"activation_mode": "code",
"starts_at": "2024-06-01T00:00:00Z",
"expires_at": "2024-08-31T23:59:59Z"
}'const response = await fetch("https://api.onbolder.com/v2/promotions", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"shop_id": 1,
"name": "Summer Sale",
"code": "SUMMER20",
"discount_type": "percentage",
"discount": 20,
"activation_mode": "code",
"starts_at": "2024-06-01T00:00:00Z",
"expires_at": "2024-08-31T23:59:59Z"
})
});import requests
response = requests.post(
"https://api.onbolder.com/v2/promotions",
headers={
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
json={
"shop_id": 1,
"name": "Summer Sale",
"code": "SUMMER20",
"discount_type": "percentage",
"discount": 20,
"activation_mode": "code",
"starts_at": "2024-06-01T00:00:00Z",
"expires_at": "2024-08-31T23:59:59Z"
},
)Response
{
"id": 20,
"name": "Summer Sale",
"code": "SUMMER20",
"discount_type": "percentage",
"discount": 20,
"status": "active",
"starts_at": "2024-06-01T00:00:00Z",
"expires_at": "2024-08-31T23:59:59Z",
"_links": {
"self": {
"href": "https://api.onbolder.com/v2/promotions/20"
}
}
}Validation error