Create promotion
curl --request POST \
--url https://staging.api.commercengine.io/api/v1/{store_id}/admin/offer/promotions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"starts_at": "2023-11-07T05:31:56Z",
"details": {
"discount_type": "percentage",
"discount_percent": 123,
"maximum_discount_amount": 123,
"products": [
{
"product_id": "<string>",
"variant_id": "<string>",
"minimum_quantity": 123,
"maximum_quantity": 123,
"minimum_value": 123,
"maximum_value": 123
}
],
"category_id": [
"<string>"
]
},
"can_be_used_with_other_promotion": true,
"description": "<string>",
"tags": [
"<string>"
],
"customer_id": [
"<string>"
],
"segment_id": [
"<string>"
],
"customer_group_id": [
"<string>"
],
"redemption_limits": {
"total_redemptions": 123,
"per_customer_redemptions": 123,
"per_coupon_code_redemptions": 123
},
"minimum_order_total": 0,
"for_first_time_customer_only": false,
"can_be_used_with_promotion": false,
"can_earn_loyalty_points": true,
"can_redeem_loyalty_points": true,
"expires_at": "2023-11-07T05:31:56Z",
"priority": 3
}
'import requests
url = "https://staging.api.commercengine.io/api/v1/{store_id}/admin/offer/promotions"
payload = {
"name": "<string>",
"starts_at": "2023-11-07T05:31:56Z",
"details": {
"discount_type": "percentage",
"discount_percent": 123,
"maximum_discount_amount": 123,
"products": [
{
"product_id": "<string>",
"variant_id": "<string>",
"minimum_quantity": 123,
"maximum_quantity": 123,
"minimum_value": 123,
"maximum_value": 123
}
],
"category_id": ["<string>"]
},
"can_be_used_with_other_promotion": True,
"description": "<string>",
"tags": ["<string>"],
"customer_id": ["<string>"],
"segment_id": ["<string>"],
"customer_group_id": ["<string>"],
"redemption_limits": {
"total_redemptions": 123,
"per_customer_redemptions": 123,
"per_coupon_code_redemptions": 123
},
"minimum_order_total": 0,
"for_first_time_customer_only": False,
"can_be_used_with_promotion": False,
"can_earn_loyalty_points": True,
"can_redeem_loyalty_points": True,
"expires_at": "2023-11-07T05:31:56Z",
"priority": 3
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
starts_at: '2023-11-07T05:31:56Z',
details: {
discount_type: 'percentage',
discount_percent: 123,
maximum_discount_amount: 123,
products: [
{
product_id: '<string>',
variant_id: '<string>',
minimum_quantity: 123,
maximum_quantity: 123,
minimum_value: 123,
maximum_value: 123
}
],
category_id: ['<string>']
},
can_be_used_with_other_promotion: true,
description: '<string>',
tags: ['<string>'],
customer_id: ['<string>'],
segment_id: ['<string>'],
customer_group_id: ['<string>'],
redemption_limits: {
total_redemptions: 123,
per_customer_redemptions: 123,
per_coupon_code_redemptions: 123
},
minimum_order_total: 0,
for_first_time_customer_only: false,
can_be_used_with_promotion: false,
can_earn_loyalty_points: true,
can_redeem_loyalty_points: true,
expires_at: '2023-11-07T05:31:56Z',
priority: 3
})
};
fetch('https://staging.api.commercengine.io/api/v1/{store_id}/admin/offer/promotions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://staging.api.commercengine.io/api/v1/{store_id}/admin/offer/promotions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'starts_at' => '2023-11-07T05:31:56Z',
'details' => [
'discount_type' => 'percentage',
'discount_percent' => 123,
'maximum_discount_amount' => 123,
'products' => [
[
'product_id' => '<string>',
'variant_id' => '<string>',
'minimum_quantity' => 123,
'maximum_quantity' => 123,
'minimum_value' => 123,
'maximum_value' => 123
]
],
'category_id' => [
'<string>'
]
],
'can_be_used_with_other_promotion' => true,
'description' => '<string>',
'tags' => [
'<string>'
],
'customer_id' => [
'<string>'
],
'segment_id' => [
'<string>'
],
'customer_group_id' => [
'<string>'
],
'redemption_limits' => [
'total_redemptions' => 123,
'per_customer_redemptions' => 123,
'per_coupon_code_redemptions' => 123
],
'minimum_order_total' => 0,
'for_first_time_customer_only' => false,
'can_be_used_with_promotion' => false,
'can_earn_loyalty_points' => true,
'can_redeem_loyalty_points' => true,
'expires_at' => '2023-11-07T05:31:56Z',
'priority' => 3
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://staging.api.commercengine.io/api/v1/{store_id}/admin/offer/promotions"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"starts_at\": \"2023-11-07T05:31:56Z\",\n \"details\": {\n \"discount_type\": \"percentage\",\n \"discount_percent\": 123,\n \"maximum_discount_amount\": 123,\n \"products\": [\n {\n \"product_id\": \"<string>\",\n \"variant_id\": \"<string>\",\n \"minimum_quantity\": 123,\n \"maximum_quantity\": 123,\n \"minimum_value\": 123,\n \"maximum_value\": 123\n }\n ],\n \"category_id\": [\n \"<string>\"\n ]\n },\n \"can_be_used_with_other_promotion\": true,\n \"description\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"customer_id\": [\n \"<string>\"\n ],\n \"segment_id\": [\n \"<string>\"\n ],\n \"customer_group_id\": [\n \"<string>\"\n ],\n \"redemption_limits\": {\n \"total_redemptions\": 123,\n \"per_customer_redemptions\": 123,\n \"per_coupon_code_redemptions\": 123\n },\n \"minimum_order_total\": 0,\n \"for_first_time_customer_only\": false,\n \"can_be_used_with_promotion\": false,\n \"can_earn_loyalty_points\": true,\n \"can_redeem_loyalty_points\": true,\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"priority\": 3\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://staging.api.commercengine.io/api/v1/{store_id}/admin/offer/promotions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"starts_at\": \"2023-11-07T05:31:56Z\",\n \"details\": {\n \"discount_type\": \"percentage\",\n \"discount_percent\": 123,\n \"maximum_discount_amount\": 123,\n \"products\": [\n {\n \"product_id\": \"<string>\",\n \"variant_id\": \"<string>\",\n \"minimum_quantity\": 123,\n \"maximum_quantity\": 123,\n \"minimum_value\": 123,\n \"maximum_value\": 123\n }\n ],\n \"category_id\": [\n \"<string>\"\n ]\n },\n \"can_be_used_with_other_promotion\": true,\n \"description\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"customer_id\": [\n \"<string>\"\n ],\n \"segment_id\": [\n \"<string>\"\n ],\n \"customer_group_id\": [\n \"<string>\"\n ],\n \"redemption_limits\": {\n \"total_redemptions\": 123,\n \"per_customer_redemptions\": 123,\n \"per_coupon_code_redemptions\": 123\n },\n \"minimum_order_total\": 0,\n \"for_first_time_customer_only\": false,\n \"can_be_used_with_promotion\": false,\n \"can_earn_loyalty_points\": true,\n \"can_redeem_loyalty_points\": true,\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"priority\": 3\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://staging.api.commercengine.io/api/v1/{store_id}/admin/offer/promotions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"starts_at\": \"2023-11-07T05:31:56Z\",\n \"details\": {\n \"discount_type\": \"percentage\",\n \"discount_percent\": 123,\n \"maximum_discount_amount\": 123,\n \"products\": [\n {\n \"product_id\": \"<string>\",\n \"variant_id\": \"<string>\",\n \"minimum_quantity\": 123,\n \"maximum_quantity\": 123,\n \"minimum_value\": 123,\n \"maximum_value\": 123\n }\n ],\n \"category_id\": [\n \"<string>\"\n ]\n },\n \"can_be_used_with_other_promotion\": true,\n \"description\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"customer_id\": [\n \"<string>\"\n ],\n \"segment_id\": [\n \"<string>\"\n ],\n \"customer_group_id\": [\n \"<string>\"\n ],\n \"redemption_limits\": {\n \"total_redemptions\": 123,\n \"per_customer_redemptions\": 123,\n \"per_coupon_code_redemptions\": 123\n },\n \"minimum_order_total\": 0,\n \"for_first_time_customer_only\": false,\n \"can_be_used_with_promotion\": false,\n \"can_earn_loyalty_points\": true,\n \"can_redeem_loyalty_points\": true,\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"priority\": 3\n}"
response = http.request(request)
puts response.read_body{
"message": "<string>",
"success": true
}Coupons & promotions
Create promotion
Create promotion
POST
/
offer
/
promotions
Create promotion
curl --request POST \
--url https://staging.api.commercengine.io/api/v1/{store_id}/admin/offer/promotions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"starts_at": "2023-11-07T05:31:56Z",
"details": {
"discount_type": "percentage",
"discount_percent": 123,
"maximum_discount_amount": 123,
"products": [
{
"product_id": "<string>",
"variant_id": "<string>",
"minimum_quantity": 123,
"maximum_quantity": 123,
"minimum_value": 123,
"maximum_value": 123
}
],
"category_id": [
"<string>"
]
},
"can_be_used_with_other_promotion": true,
"description": "<string>",
"tags": [
"<string>"
],
"customer_id": [
"<string>"
],
"segment_id": [
"<string>"
],
"customer_group_id": [
"<string>"
],
"redemption_limits": {
"total_redemptions": 123,
"per_customer_redemptions": 123,
"per_coupon_code_redemptions": 123
},
"minimum_order_total": 0,
"for_first_time_customer_only": false,
"can_be_used_with_promotion": false,
"can_earn_loyalty_points": true,
"can_redeem_loyalty_points": true,
"expires_at": "2023-11-07T05:31:56Z",
"priority": 3
}
'import requests
url = "https://staging.api.commercengine.io/api/v1/{store_id}/admin/offer/promotions"
payload = {
"name": "<string>",
"starts_at": "2023-11-07T05:31:56Z",
"details": {
"discount_type": "percentage",
"discount_percent": 123,
"maximum_discount_amount": 123,
"products": [
{
"product_id": "<string>",
"variant_id": "<string>",
"minimum_quantity": 123,
"maximum_quantity": 123,
"minimum_value": 123,
"maximum_value": 123
}
],
"category_id": ["<string>"]
},
"can_be_used_with_other_promotion": True,
"description": "<string>",
"tags": ["<string>"],
"customer_id": ["<string>"],
"segment_id": ["<string>"],
"customer_group_id": ["<string>"],
"redemption_limits": {
"total_redemptions": 123,
"per_customer_redemptions": 123,
"per_coupon_code_redemptions": 123
},
"minimum_order_total": 0,
"for_first_time_customer_only": False,
"can_be_used_with_promotion": False,
"can_earn_loyalty_points": True,
"can_redeem_loyalty_points": True,
"expires_at": "2023-11-07T05:31:56Z",
"priority": 3
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
starts_at: '2023-11-07T05:31:56Z',
details: {
discount_type: 'percentage',
discount_percent: 123,
maximum_discount_amount: 123,
products: [
{
product_id: '<string>',
variant_id: '<string>',
minimum_quantity: 123,
maximum_quantity: 123,
minimum_value: 123,
maximum_value: 123
}
],
category_id: ['<string>']
},
can_be_used_with_other_promotion: true,
description: '<string>',
tags: ['<string>'],
customer_id: ['<string>'],
segment_id: ['<string>'],
customer_group_id: ['<string>'],
redemption_limits: {
total_redemptions: 123,
per_customer_redemptions: 123,
per_coupon_code_redemptions: 123
},
minimum_order_total: 0,
for_first_time_customer_only: false,
can_be_used_with_promotion: false,
can_earn_loyalty_points: true,
can_redeem_loyalty_points: true,
expires_at: '2023-11-07T05:31:56Z',
priority: 3
})
};
fetch('https://staging.api.commercengine.io/api/v1/{store_id}/admin/offer/promotions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://staging.api.commercengine.io/api/v1/{store_id}/admin/offer/promotions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'starts_at' => '2023-11-07T05:31:56Z',
'details' => [
'discount_type' => 'percentage',
'discount_percent' => 123,
'maximum_discount_amount' => 123,
'products' => [
[
'product_id' => '<string>',
'variant_id' => '<string>',
'minimum_quantity' => 123,
'maximum_quantity' => 123,
'minimum_value' => 123,
'maximum_value' => 123
]
],
'category_id' => [
'<string>'
]
],
'can_be_used_with_other_promotion' => true,
'description' => '<string>',
'tags' => [
'<string>'
],
'customer_id' => [
'<string>'
],
'segment_id' => [
'<string>'
],
'customer_group_id' => [
'<string>'
],
'redemption_limits' => [
'total_redemptions' => 123,
'per_customer_redemptions' => 123,
'per_coupon_code_redemptions' => 123
],
'minimum_order_total' => 0,
'for_first_time_customer_only' => false,
'can_be_used_with_promotion' => false,
'can_earn_loyalty_points' => true,
'can_redeem_loyalty_points' => true,
'expires_at' => '2023-11-07T05:31:56Z',
'priority' => 3
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://staging.api.commercengine.io/api/v1/{store_id}/admin/offer/promotions"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"starts_at\": \"2023-11-07T05:31:56Z\",\n \"details\": {\n \"discount_type\": \"percentage\",\n \"discount_percent\": 123,\n \"maximum_discount_amount\": 123,\n \"products\": [\n {\n \"product_id\": \"<string>\",\n \"variant_id\": \"<string>\",\n \"minimum_quantity\": 123,\n \"maximum_quantity\": 123,\n \"minimum_value\": 123,\n \"maximum_value\": 123\n }\n ],\n \"category_id\": [\n \"<string>\"\n ]\n },\n \"can_be_used_with_other_promotion\": true,\n \"description\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"customer_id\": [\n \"<string>\"\n ],\n \"segment_id\": [\n \"<string>\"\n ],\n \"customer_group_id\": [\n \"<string>\"\n ],\n \"redemption_limits\": {\n \"total_redemptions\": 123,\n \"per_customer_redemptions\": 123,\n \"per_coupon_code_redemptions\": 123\n },\n \"minimum_order_total\": 0,\n \"for_first_time_customer_only\": false,\n \"can_be_used_with_promotion\": false,\n \"can_earn_loyalty_points\": true,\n \"can_redeem_loyalty_points\": true,\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"priority\": 3\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://staging.api.commercengine.io/api/v1/{store_id}/admin/offer/promotions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"starts_at\": \"2023-11-07T05:31:56Z\",\n \"details\": {\n \"discount_type\": \"percentage\",\n \"discount_percent\": 123,\n \"maximum_discount_amount\": 123,\n \"products\": [\n {\n \"product_id\": \"<string>\",\n \"variant_id\": \"<string>\",\n \"minimum_quantity\": 123,\n \"maximum_quantity\": 123,\n \"minimum_value\": 123,\n \"maximum_value\": 123\n }\n ],\n \"category_id\": [\n \"<string>\"\n ]\n },\n \"can_be_used_with_other_promotion\": true,\n \"description\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"customer_id\": [\n \"<string>\"\n ],\n \"segment_id\": [\n \"<string>\"\n ],\n \"customer_group_id\": [\n \"<string>\"\n ],\n \"redemption_limits\": {\n \"total_redemptions\": 123,\n \"per_customer_redemptions\": 123,\n \"per_coupon_code_redemptions\": 123\n },\n \"minimum_order_total\": 0,\n \"for_first_time_customer_only\": false,\n \"can_be_used_with_promotion\": false,\n \"can_earn_loyalty_points\": true,\n \"can_redeem_loyalty_points\": true,\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"priority\": 3\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://staging.api.commercengine.io/api/v1/{store_id}/admin/offer/promotions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"starts_at\": \"2023-11-07T05:31:56Z\",\n \"details\": {\n \"discount_type\": \"percentage\",\n \"discount_percent\": 123,\n \"maximum_discount_amount\": 123,\n \"products\": [\n {\n \"product_id\": \"<string>\",\n \"variant_id\": \"<string>\",\n \"minimum_quantity\": 123,\n \"maximum_quantity\": 123,\n \"minimum_value\": 123,\n \"maximum_value\": 123\n }\n ],\n \"category_id\": [\n \"<string>\"\n ]\n },\n \"can_be_used_with_other_promotion\": true,\n \"description\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"customer_id\": [\n \"<string>\"\n ],\n \"segment_id\": [\n \"<string>\"\n ],\n \"customer_group_id\": [\n \"<string>\"\n ],\n \"redemption_limits\": {\n \"total_redemptions\": 123,\n \"per_customer_redemptions\": 123,\n \"per_coupon_code_redemptions\": 123\n },\n \"minimum_order_total\": 0,\n \"for_first_time_customer_only\": false,\n \"can_be_used_with_promotion\": false,\n \"can_earn_loyalty_points\": true,\n \"can_redeem_loyalty_points\": true,\n \"expires_at\": \"2023-11-07T05:31:56Z\",\n \"priority\": 3\n}"
response = http.request(request)
puts response.read_body{
"message": "<string>",
"success": true
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
- Promotion
- Promotion
- Promotion
- Promotion
- Promotion
- Promotion
this key is ignored in create coupon api and draft status will be added by default. required in update coupon api only.
Available options:
draft, scheduled, active, inactive Available options:
all, customer, segment, customer-group - PercentageDiscountRule
- FixedAmountDiscountRule
Show child attributes
Show child attributes
Available options:
all, product, category Available options:
discount, tiered-discount, free-goods, free-shipping, buy-x-get-y, volume-based required if customer_eligibility = customer
required if customer_eligibility = segment
Show child attributes
Show child attributes
Ignored when coupon_type or promotion_type is tiered-discount. Each slab in details defines its own order_value threshold.
Required range:
1 <= x <= 5Was this page helpful?
⌘I