Backend API
Create a new promotion.
Arguments
A short descriptive name of the promo.
A brief description of the promo, as it may be displayed to customers.
Indicates the promo is currently active. Note: this is not affected by date_start and date_end.
Date the promo is first available. When defined, the promo will not be valid until after this date and before date_end.
Date the promo ends and is no longer available. When defined, the promo will not be applied after this date.
List of discount rules to apply.
Type of discount to apply. Can be total, product, category, or shipment.
Possible enum values:
Type of discount amount to calculate. Can be fixed or percent.
Possible enum values:
Fixed discount applied when value_type=fixed.
Percentage discount applied when value_type=percent.
Minimum order total required for the rule to apply.
The maximum amount of a discount that can be redeemed.
The minimum amount of a discount that can be redeemed.
Minimum product quantity required for the rule to apply, applicable for category and product discounts.
Maximum product quantity for which the rule will apply, applicable for category and product discounts.
ID of the product to discount, if applicable.
ID of the variant to discount, if applicable.
ID of the shipping service to discount, if applicable.
ID of the category to discount, if applicable.
List of category IDs to exclude from discount, applicable to category discounts when several categories overlap.
Expandable link to the discounted product, if applicable.
Expandable link to the discounted variant, if applicable.
Expandable link to the discounted category, if applicable.
Expandable list of excluded categories, if applicable.
Items required to be purchased in order to receive the promotion.
ID of the product that is tied to the promotion eligibility, if applicable.
Expandable link to the promotion-eligible product, if applicable.
ID of the category that is tied to the promotion eligibility, if applicable.
Expandable link to the promotion-eligible category, if applicable.
Eligible discounted items available once promotion's buy_items requirements are met.
ID of the product to discount, if applicable.
Expandable link to the discounted product, if applicable.
ID of the discounted category, if applicable.
Expandable link to the discounted category, if applicable.
Indicates whether the get_items promotion requirements have been met.
Number of times the promo has been applied.
Maximum number of times the promo will be applied across all customers.
Maximum number of times the promo will be applied by each customer account.
List of customer account for which the promo will apply.
ID of the discount group the promo belongs to, if applicable, as defined in discount settings. Used to ensure only one set of discount rules can apply across a number of coupons and promotions.
List of exclusions considered when the promo is applied.
The type of exclusion for the promotion. Can be either product or category.
Possible enum values:
ID of the product to exclude from the discount, if applicable.
ID of the category to exclude from the discount, if applicable.
Expandable link to the excluded product, if applicable.
Expandable link to the excluded category, if applicable.
Expandable list of promo usage records.
Expandable list of orders that have applied the promo.
Expandable list of subscriptions that have applied the promo.
Three-letter ISO currency code in uppercase. Defaults to the store's base currency.
const { swell } = require('swell-node');
swell.init('store-id', 'secret-key');
await swell.post('/promotions', {
discounts: [
{
type: 'total',
value_type: 'percent',
value_fixed: 15
}
],
name: '15% Off Store Wide Sale',
active: true,
date_end: '2018-03-01T00:00:00.000Z',
date_start: '2018-11-01T00:00:00.000Z',
description: 'Save 15% store wide for a limited time only.'
});
Response
{
"id": "60f199509111e7000000006b",
"name": "15% Off Store Wide Sale",
"active": true,
"currency": "USD",
"date_created": "2021-07-16T14:36:00.386Z",
"date_end": "2018-03-01T00:00:00.000Z",
"date_start": "2018-11-01T00:00:00.000Z",
"date_updated": "2021-07-16T14:36:00.386Z",
"description": "Save 15% store wide for a limited time only.",
"discounts": [
{
"type": "total",
"value_type": "percent",
"value_fixed": 15
}
],
"limit_account_uses": 3,
"limit_uses": 300,
"use_count": 142
}