curl --request POST \
--url https://live.copilot.fabric.inc/api-offers/coupon/create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-site-context: <x-site-context>' \
--data '
{
"title": "CREATE COUPON",
"promo": [
{
"discount": [
{
"unit": "%OFF",
"value": 10,
"ON": {
"kind": "SKU",
"value": "*",
"quantity": 2,
"includeOperator": "OR",
"excludeOperator": "AND"
},
"discountId": 1,
"autoAdd": false,
"set": []
}
],
"targetProducts": [
{
"kind": "SKU",
"value": "*",
"operator": "IN",
"discountId": 1
}
],
"condition": [
{
"conditions": [
{
"key": "SKU",
"value": "*",
"operator": "IN"
}
],
"includeOperator": "OR",
"excludeOperator": "AND",
"set": "A"
}
]
}
],
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-25T14:15:22Z",
"isExclusive": true,
"type": "PRODUCT",
"promoCodes": [
[
"SUMMER100",
"SUMMER20"
]
],
"buyOperator": "OR",
"stackingType": "STACKABLE",
"level": 1,
"termsAndConditions": [
{
"title": "Terms Applied",
"description": "Items cannot be exchanged"
}
],
"promotionMessages": [
{
"title": "Buy 1 get 1 free",
"message": "Offer valid at participating stores through September 5, 2023.",
"pages": [
"PDP",
"Cart"
],
"locales": [
"en-CA",
"fr-CA"
]
}
],
"proximityMessages": [
{
"threshold": 1,
"localizedMessages": [
{
"locales": [
"<string>"
],
"message": "<string>"
}
]
}
],
"shipmentMethodIds": [
"1000001"
],
"eligiblePriceList": [
10000056
],
"note": "Independence day sale!",
"limits": [
{
"kind": "ORDER",
"value": 2
}
],
"additionalAttributes": [
{
"key": "type",
"value": "Birthday",
"attributeId": 100000
}
]
}
'import requests
url = "https://live.copilot.fabric.inc/api-offers/coupon/create"
payload = {
"title": "CREATE COUPON",
"promo": [
{
"discount": [
{
"unit": "%OFF",
"value": 10,
"ON": {
"kind": "SKU",
"value": "*",
"quantity": 2,
"includeOperator": "OR",
"excludeOperator": "AND"
},
"discountId": 1,
"autoAdd": False,
"set": []
}
],
"targetProducts": [
{
"kind": "SKU",
"value": "*",
"operator": "IN",
"discountId": 1
}
],
"condition": [
{
"conditions": [
{
"key": "SKU",
"value": "*",
"operator": "IN"
}
],
"includeOperator": "OR",
"excludeOperator": "AND",
"set": "A"
}
]
}
],
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-25T14:15:22Z",
"isExclusive": True,
"type": "PRODUCT",
"promoCodes": [["SUMMER100", "SUMMER20"]],
"buyOperator": "OR",
"stackingType": "STACKABLE",
"level": 1,
"termsAndConditions": [
{
"title": "Terms Applied",
"description": "Items cannot be exchanged"
}
],
"promotionMessages": [
{
"title": "Buy 1 get 1 free",
"message": "Offer valid at participating stores through September 5, 2023.",
"pages": ["PDP", "Cart"],
"locales": ["en-CA", "fr-CA"]
}
],
"proximityMessages": [
{
"threshold": 1,
"localizedMessages": [
{
"locales": ["<string>"],
"message": "<string>"
}
]
}
],
"shipmentMethodIds": ["1000001"],
"eligiblePriceList": [10000056],
"note": "Independence day sale!",
"limits": [
{
"kind": "ORDER",
"value": 2
}
],
"additionalAttributes": [
{
"key": "type",
"value": "Birthday",
"attributeId": 100000
}
]
}
headers = {
"x-site-context": "<x-site-context>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-site-context': '<x-site-context>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
title: 'CREATE COUPON',
promo: [
{
discount: [
{
unit: '%OFF',
value: 10,
ON: {
kind: 'SKU',
value: '*',
quantity: 2,
includeOperator: 'OR',
excludeOperator: 'AND'
},
discountId: 1,
autoAdd: false,
set: []
}
],
targetProducts: [{kind: 'SKU', value: '*', operator: 'IN', discountId: 1}],
condition: [
{
conditions: [{key: 'SKU', value: '*', operator: 'IN'}],
includeOperator: 'OR',
excludeOperator: 'AND',
set: 'A'
}
]
}
],
startDate: '2019-08-24T14:15:22Z',
endDate: '2019-08-25T14:15:22Z',
isExclusive: true,
type: 'PRODUCT',
promoCodes: [['SUMMER100', 'SUMMER20']],
buyOperator: 'OR',
stackingType: 'STACKABLE',
level: 1,
termsAndConditions: [{title: 'Terms Applied', description: 'Items cannot be exchanged'}],
promotionMessages: [
{
title: 'Buy 1 get 1 free',
message: 'Offer valid at participating stores through September 5, 2023.',
pages: ['PDP', 'Cart'],
locales: ['en-CA', 'fr-CA']
}
],
proximityMessages: [
{
threshold: 1,
localizedMessages: [{locales: ['<string>'], message: '<string>'}]
}
],
shipmentMethodIds: ['1000001'],
eligiblePriceList: [10000056],
note: 'Independence day sale!',
limits: [{kind: 'ORDER', value: 2}],
additionalAttributes: [{key: 'type', value: 'Birthday', attributeId: 100000}]
})
};
fetch('https://live.copilot.fabric.inc/api-offers/coupon/create', 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://live.copilot.fabric.inc/api-offers/coupon/create",
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([
'title' => 'CREATE COUPON',
'promo' => [
[
'discount' => [
[
'unit' => '%OFF',
'value' => 10,
'ON' => [
'kind' => 'SKU',
'value' => '*',
'quantity' => 2,
'includeOperator' => 'OR',
'excludeOperator' => 'AND'
],
'discountId' => 1,
'autoAdd' => false,
'set' => [
]
]
],
'targetProducts' => [
[
'kind' => 'SKU',
'value' => '*',
'operator' => 'IN',
'discountId' => 1
]
],
'condition' => [
[
'conditions' => [
[
'key' => 'SKU',
'value' => '*',
'operator' => 'IN'
]
],
'includeOperator' => 'OR',
'excludeOperator' => 'AND',
'set' => 'A'
]
]
]
],
'startDate' => '2019-08-24T14:15:22Z',
'endDate' => '2019-08-25T14:15:22Z',
'isExclusive' => true,
'type' => 'PRODUCT',
'promoCodes' => [
[
'SUMMER100',
'SUMMER20'
]
],
'buyOperator' => 'OR',
'stackingType' => 'STACKABLE',
'level' => 1,
'termsAndConditions' => [
[
'title' => 'Terms Applied',
'description' => 'Items cannot be exchanged'
]
],
'promotionMessages' => [
[
'title' => 'Buy 1 get 1 free',
'message' => 'Offer valid at participating stores through September 5, 2023.',
'pages' => [
'PDP',
'Cart'
],
'locales' => [
'en-CA',
'fr-CA'
]
]
],
'proximityMessages' => [
[
'threshold' => 1,
'localizedMessages' => [
[
'locales' => [
'<string>'
],
'message' => '<string>'
]
]
]
],
'shipmentMethodIds' => [
'1000001'
],
'eligiblePriceList' => [
10000056
],
'note' => 'Independence day sale!',
'limits' => [
[
'kind' => 'ORDER',
'value' => 2
]
],
'additionalAttributes' => [
[
'key' => 'type',
'value' => 'Birthday',
'attributeId' => 100000
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-site-context: <x-site-context>"
],
]);
$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://live.copilot.fabric.inc/api-offers/coupon/create"
payload := strings.NewReader("{\n \"title\": \"CREATE COUPON\",\n \"promo\": [\n {\n \"discount\": [\n {\n \"unit\": \"%OFF\",\n \"value\": 10,\n \"ON\": {\n \"kind\": \"SKU\",\n \"value\": \"*\",\n \"quantity\": 2,\n \"includeOperator\": \"OR\",\n \"excludeOperator\": \"AND\"\n },\n \"discountId\": 1,\n \"autoAdd\": false,\n \"set\": []\n }\n ],\n \"targetProducts\": [\n {\n \"kind\": \"SKU\",\n \"value\": \"*\",\n \"operator\": \"IN\",\n \"discountId\": 1\n }\n ],\n \"condition\": [\n {\n \"conditions\": [\n {\n \"key\": \"SKU\",\n \"value\": \"*\",\n \"operator\": \"IN\"\n }\n ],\n \"includeOperator\": \"OR\",\n \"excludeOperator\": \"AND\",\n \"set\": \"A\"\n }\n ]\n }\n ],\n \"startDate\": \"2019-08-24T14:15:22Z\",\n \"endDate\": \"2019-08-25T14:15:22Z\",\n \"isExclusive\": true,\n \"type\": \"PRODUCT\",\n \"promoCodes\": [\n [\n \"SUMMER100\",\n \"SUMMER20\"\n ]\n ],\n \"buyOperator\": \"OR\",\n \"stackingType\": \"STACKABLE\",\n \"level\": 1,\n \"termsAndConditions\": [\n {\n \"title\": \"Terms Applied\",\n \"description\": \"Items cannot be exchanged\"\n }\n ],\n \"promotionMessages\": [\n {\n \"title\": \"Buy 1 get 1 free\",\n \"message\": \"Offer valid at participating stores through September 5, 2023.\",\n \"pages\": [\n \"PDP\",\n \"Cart\"\n ],\n \"locales\": [\n \"en-CA\",\n \"fr-CA\"\n ]\n }\n ],\n \"proximityMessages\": [\n {\n \"threshold\": 1,\n \"localizedMessages\": [\n {\n \"locales\": [\n \"<string>\"\n ],\n \"message\": \"<string>\"\n }\n ]\n }\n ],\n \"shipmentMethodIds\": [\n \"1000001\"\n ],\n \"eligiblePriceList\": [\n 10000056\n ],\n \"note\": \"Independence day sale!\",\n \"limits\": [\n {\n \"kind\": \"ORDER\",\n \"value\": 2\n }\n ],\n \"additionalAttributes\": [\n {\n \"key\": \"type\",\n \"value\": \"Birthday\",\n \"attributeId\": 100000\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-site-context", "<x-site-context>")
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://live.copilot.fabric.inc/api-offers/coupon/create")
.header("x-site-context", "<x-site-context>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"CREATE COUPON\",\n \"promo\": [\n {\n \"discount\": [\n {\n \"unit\": \"%OFF\",\n \"value\": 10,\n \"ON\": {\n \"kind\": \"SKU\",\n \"value\": \"*\",\n \"quantity\": 2,\n \"includeOperator\": \"OR\",\n \"excludeOperator\": \"AND\"\n },\n \"discountId\": 1,\n \"autoAdd\": false,\n \"set\": []\n }\n ],\n \"targetProducts\": [\n {\n \"kind\": \"SKU\",\n \"value\": \"*\",\n \"operator\": \"IN\",\n \"discountId\": 1\n }\n ],\n \"condition\": [\n {\n \"conditions\": [\n {\n \"key\": \"SKU\",\n \"value\": \"*\",\n \"operator\": \"IN\"\n }\n ],\n \"includeOperator\": \"OR\",\n \"excludeOperator\": \"AND\",\n \"set\": \"A\"\n }\n ]\n }\n ],\n \"startDate\": \"2019-08-24T14:15:22Z\",\n \"endDate\": \"2019-08-25T14:15:22Z\",\n \"isExclusive\": true,\n \"type\": \"PRODUCT\",\n \"promoCodes\": [\n [\n \"SUMMER100\",\n \"SUMMER20\"\n ]\n ],\n \"buyOperator\": \"OR\",\n \"stackingType\": \"STACKABLE\",\n \"level\": 1,\n \"termsAndConditions\": [\n {\n \"title\": \"Terms Applied\",\n \"description\": \"Items cannot be exchanged\"\n }\n ],\n \"promotionMessages\": [\n {\n \"title\": \"Buy 1 get 1 free\",\n \"message\": \"Offer valid at participating stores through September 5, 2023.\",\n \"pages\": [\n \"PDP\",\n \"Cart\"\n ],\n \"locales\": [\n \"en-CA\",\n \"fr-CA\"\n ]\n }\n ],\n \"proximityMessages\": [\n {\n \"threshold\": 1,\n \"localizedMessages\": [\n {\n \"locales\": [\n \"<string>\"\n ],\n \"message\": \"<string>\"\n }\n ]\n }\n ],\n \"shipmentMethodIds\": [\n \"1000001\"\n ],\n \"eligiblePriceList\": [\n 10000056\n ],\n \"note\": \"Independence day sale!\",\n \"limits\": [\n {\n \"kind\": \"ORDER\",\n \"value\": 2\n }\n ],\n \"additionalAttributes\": [\n {\n \"key\": \"type\",\n \"value\": \"Birthday\",\n \"attributeId\": 100000\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://live.copilot.fabric.inc/api-offers/coupon/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-site-context"] = '<x-site-context>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"title\": \"CREATE COUPON\",\n \"promo\": [\n {\n \"discount\": [\n {\n \"unit\": \"%OFF\",\n \"value\": 10,\n \"ON\": {\n \"kind\": \"SKU\",\n \"value\": \"*\",\n \"quantity\": 2,\n \"includeOperator\": \"OR\",\n \"excludeOperator\": \"AND\"\n },\n \"discountId\": 1,\n \"autoAdd\": false,\n \"set\": []\n }\n ],\n \"targetProducts\": [\n {\n \"kind\": \"SKU\",\n \"value\": \"*\",\n \"operator\": \"IN\",\n \"discountId\": 1\n }\n ],\n \"condition\": [\n {\n \"conditions\": [\n {\n \"key\": \"SKU\",\n \"value\": \"*\",\n \"operator\": \"IN\"\n }\n ],\n \"includeOperator\": \"OR\",\n \"excludeOperator\": \"AND\",\n \"set\": \"A\"\n }\n ]\n }\n ],\n \"startDate\": \"2019-08-24T14:15:22Z\",\n \"endDate\": \"2019-08-25T14:15:22Z\",\n \"isExclusive\": true,\n \"type\": \"PRODUCT\",\n \"promoCodes\": [\n [\n \"SUMMER100\",\n \"SUMMER20\"\n ]\n ],\n \"buyOperator\": \"OR\",\n \"stackingType\": \"STACKABLE\",\n \"level\": 1,\n \"termsAndConditions\": [\n {\n \"title\": \"Terms Applied\",\n \"description\": \"Items cannot be exchanged\"\n }\n ],\n \"promotionMessages\": [\n {\n \"title\": \"Buy 1 get 1 free\",\n \"message\": \"Offer valid at participating stores through September 5, 2023.\",\n \"pages\": [\n \"PDP\",\n \"Cart\"\n ],\n \"locales\": [\n \"en-CA\",\n \"fr-CA\"\n ]\n }\n ],\n \"proximityMessages\": [\n {\n \"threshold\": 1,\n \"localizedMessages\": [\n {\n \"locales\": [\n \"<string>\"\n ],\n \"message\": \"<string>\"\n }\n ]\n }\n ],\n \"shipmentMethodIds\": [\n \"1000001\"\n ],\n \"eligiblePriceList\": [\n 10000056\n ],\n \"note\": \"Independence day sale!\",\n \"limits\": [\n {\n \"kind\": \"ORDER\",\n \"value\": 2\n }\n ],\n \"additionalAttributes\": [\n {\n \"key\": \"type\",\n \"value\": \"Birthday\",\n \"attributeId\": 100000\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"_id": "abcdefg1ee7ce20123456789",
"promoId": 100013,
"promoCodes": [
"SUMMER100",
"SUMMER20"
],
"state": "SCHEDULED",
"isImplicit": false,
"title": "CREATE PROMO",
"buyOperator": "OR",
"promo": [
{
"discount": [
{
"unit": "%OFF",
"value": 10,
"ON": {
"kind": "SKU",
"value": "*",
"quantity": 2,
"includeOperator": "OR",
"excludeOperator": "AND"
},
"discountId": 1,
"autoAdd": false,
"set": [
"A"
]
}
],
"targetProducts": [
{
"kind": "SKU",
"value": "*",
"operator": "IN",
"discountId": 1
}
],
"condition": [
"620d84a715f2d00001234567"
]
}
],
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-25T14:15:22Z",
"isExclusive": true,
"type": "PRODUCT",
"stackingType": "STACKABLE",
"level": 1,
"termsAndConditions": [
{
"title": "Terms Applied",
"description": "Items cannot be exchanged"
}
],
"promotionMessages": [
{
"title": "Buy 1 get 1 free",
"message": "Offer valid at participating stores through September 5, 2023.",
"pages": [
"PDP",
"Cart"
],
"locales": [
"en-CA",
"fr-CA"
]
}
],
"proximityMessages": [
{
"threshold": 1,
"localizedMessages": [
{
"locales": [
"<string>"
],
"message": "<string>"
}
]
}
],
"shipmentMethodIds": [
1000001
],
"eligiblePriceList": [
10000056
],
"limits": [
{
"kind": "ORDER",
"value": 2
}
],
"note": "Independence day sale!",
"createdAt": "2019-08-20T14:15:22Z",
"updatedAt": "2019-08-20T14:15:22Z"
}{
"code": "DATE_ERROR",
"message": "The start date should be earlier than the end date and it should be a future date."
}{
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal server error."
}Create coupon
Enables you to create a coupon that can be applied to get discounts
curl --request POST \
--url https://live.copilot.fabric.inc/api-offers/coupon/create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'x-site-context: <x-site-context>' \
--data '
{
"title": "CREATE COUPON",
"promo": [
{
"discount": [
{
"unit": "%OFF",
"value": 10,
"ON": {
"kind": "SKU",
"value": "*",
"quantity": 2,
"includeOperator": "OR",
"excludeOperator": "AND"
},
"discountId": 1,
"autoAdd": false,
"set": []
}
],
"targetProducts": [
{
"kind": "SKU",
"value": "*",
"operator": "IN",
"discountId": 1
}
],
"condition": [
{
"conditions": [
{
"key": "SKU",
"value": "*",
"operator": "IN"
}
],
"includeOperator": "OR",
"excludeOperator": "AND",
"set": "A"
}
]
}
],
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-25T14:15:22Z",
"isExclusive": true,
"type": "PRODUCT",
"promoCodes": [
[
"SUMMER100",
"SUMMER20"
]
],
"buyOperator": "OR",
"stackingType": "STACKABLE",
"level": 1,
"termsAndConditions": [
{
"title": "Terms Applied",
"description": "Items cannot be exchanged"
}
],
"promotionMessages": [
{
"title": "Buy 1 get 1 free",
"message": "Offer valid at participating stores through September 5, 2023.",
"pages": [
"PDP",
"Cart"
],
"locales": [
"en-CA",
"fr-CA"
]
}
],
"proximityMessages": [
{
"threshold": 1,
"localizedMessages": [
{
"locales": [
"<string>"
],
"message": "<string>"
}
]
}
],
"shipmentMethodIds": [
"1000001"
],
"eligiblePriceList": [
10000056
],
"note": "Independence day sale!",
"limits": [
{
"kind": "ORDER",
"value": 2
}
],
"additionalAttributes": [
{
"key": "type",
"value": "Birthday",
"attributeId": 100000
}
]
}
'import requests
url = "https://live.copilot.fabric.inc/api-offers/coupon/create"
payload = {
"title": "CREATE COUPON",
"promo": [
{
"discount": [
{
"unit": "%OFF",
"value": 10,
"ON": {
"kind": "SKU",
"value": "*",
"quantity": 2,
"includeOperator": "OR",
"excludeOperator": "AND"
},
"discountId": 1,
"autoAdd": False,
"set": []
}
],
"targetProducts": [
{
"kind": "SKU",
"value": "*",
"operator": "IN",
"discountId": 1
}
],
"condition": [
{
"conditions": [
{
"key": "SKU",
"value": "*",
"operator": "IN"
}
],
"includeOperator": "OR",
"excludeOperator": "AND",
"set": "A"
}
]
}
],
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-25T14:15:22Z",
"isExclusive": True,
"type": "PRODUCT",
"promoCodes": [["SUMMER100", "SUMMER20"]],
"buyOperator": "OR",
"stackingType": "STACKABLE",
"level": 1,
"termsAndConditions": [
{
"title": "Terms Applied",
"description": "Items cannot be exchanged"
}
],
"promotionMessages": [
{
"title": "Buy 1 get 1 free",
"message": "Offer valid at participating stores through September 5, 2023.",
"pages": ["PDP", "Cart"],
"locales": ["en-CA", "fr-CA"]
}
],
"proximityMessages": [
{
"threshold": 1,
"localizedMessages": [
{
"locales": ["<string>"],
"message": "<string>"
}
]
}
],
"shipmentMethodIds": ["1000001"],
"eligiblePriceList": [10000056],
"note": "Independence day sale!",
"limits": [
{
"kind": "ORDER",
"value": 2
}
],
"additionalAttributes": [
{
"key": "type",
"value": "Birthday",
"attributeId": 100000
}
]
}
headers = {
"x-site-context": "<x-site-context>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-site-context': '<x-site-context>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
title: 'CREATE COUPON',
promo: [
{
discount: [
{
unit: '%OFF',
value: 10,
ON: {
kind: 'SKU',
value: '*',
quantity: 2,
includeOperator: 'OR',
excludeOperator: 'AND'
},
discountId: 1,
autoAdd: false,
set: []
}
],
targetProducts: [{kind: 'SKU', value: '*', operator: 'IN', discountId: 1}],
condition: [
{
conditions: [{key: 'SKU', value: '*', operator: 'IN'}],
includeOperator: 'OR',
excludeOperator: 'AND',
set: 'A'
}
]
}
],
startDate: '2019-08-24T14:15:22Z',
endDate: '2019-08-25T14:15:22Z',
isExclusive: true,
type: 'PRODUCT',
promoCodes: [['SUMMER100', 'SUMMER20']],
buyOperator: 'OR',
stackingType: 'STACKABLE',
level: 1,
termsAndConditions: [{title: 'Terms Applied', description: 'Items cannot be exchanged'}],
promotionMessages: [
{
title: 'Buy 1 get 1 free',
message: 'Offer valid at participating stores through September 5, 2023.',
pages: ['PDP', 'Cart'],
locales: ['en-CA', 'fr-CA']
}
],
proximityMessages: [
{
threshold: 1,
localizedMessages: [{locales: ['<string>'], message: '<string>'}]
}
],
shipmentMethodIds: ['1000001'],
eligiblePriceList: [10000056],
note: 'Independence day sale!',
limits: [{kind: 'ORDER', value: 2}],
additionalAttributes: [{key: 'type', value: 'Birthday', attributeId: 100000}]
})
};
fetch('https://live.copilot.fabric.inc/api-offers/coupon/create', 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://live.copilot.fabric.inc/api-offers/coupon/create",
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([
'title' => 'CREATE COUPON',
'promo' => [
[
'discount' => [
[
'unit' => '%OFF',
'value' => 10,
'ON' => [
'kind' => 'SKU',
'value' => '*',
'quantity' => 2,
'includeOperator' => 'OR',
'excludeOperator' => 'AND'
],
'discountId' => 1,
'autoAdd' => false,
'set' => [
]
]
],
'targetProducts' => [
[
'kind' => 'SKU',
'value' => '*',
'operator' => 'IN',
'discountId' => 1
]
],
'condition' => [
[
'conditions' => [
[
'key' => 'SKU',
'value' => '*',
'operator' => 'IN'
]
],
'includeOperator' => 'OR',
'excludeOperator' => 'AND',
'set' => 'A'
]
]
]
],
'startDate' => '2019-08-24T14:15:22Z',
'endDate' => '2019-08-25T14:15:22Z',
'isExclusive' => true,
'type' => 'PRODUCT',
'promoCodes' => [
[
'SUMMER100',
'SUMMER20'
]
],
'buyOperator' => 'OR',
'stackingType' => 'STACKABLE',
'level' => 1,
'termsAndConditions' => [
[
'title' => 'Terms Applied',
'description' => 'Items cannot be exchanged'
]
],
'promotionMessages' => [
[
'title' => 'Buy 1 get 1 free',
'message' => 'Offer valid at participating stores through September 5, 2023.',
'pages' => [
'PDP',
'Cart'
],
'locales' => [
'en-CA',
'fr-CA'
]
]
],
'proximityMessages' => [
[
'threshold' => 1,
'localizedMessages' => [
[
'locales' => [
'<string>'
],
'message' => '<string>'
]
]
]
],
'shipmentMethodIds' => [
'1000001'
],
'eligiblePriceList' => [
10000056
],
'note' => 'Independence day sale!',
'limits' => [
[
'kind' => 'ORDER',
'value' => 2
]
],
'additionalAttributes' => [
[
'key' => 'type',
'value' => 'Birthday',
'attributeId' => 100000
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"x-site-context: <x-site-context>"
],
]);
$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://live.copilot.fabric.inc/api-offers/coupon/create"
payload := strings.NewReader("{\n \"title\": \"CREATE COUPON\",\n \"promo\": [\n {\n \"discount\": [\n {\n \"unit\": \"%OFF\",\n \"value\": 10,\n \"ON\": {\n \"kind\": \"SKU\",\n \"value\": \"*\",\n \"quantity\": 2,\n \"includeOperator\": \"OR\",\n \"excludeOperator\": \"AND\"\n },\n \"discountId\": 1,\n \"autoAdd\": false,\n \"set\": []\n }\n ],\n \"targetProducts\": [\n {\n \"kind\": \"SKU\",\n \"value\": \"*\",\n \"operator\": \"IN\",\n \"discountId\": 1\n }\n ],\n \"condition\": [\n {\n \"conditions\": [\n {\n \"key\": \"SKU\",\n \"value\": \"*\",\n \"operator\": \"IN\"\n }\n ],\n \"includeOperator\": \"OR\",\n \"excludeOperator\": \"AND\",\n \"set\": \"A\"\n }\n ]\n }\n ],\n \"startDate\": \"2019-08-24T14:15:22Z\",\n \"endDate\": \"2019-08-25T14:15:22Z\",\n \"isExclusive\": true,\n \"type\": \"PRODUCT\",\n \"promoCodes\": [\n [\n \"SUMMER100\",\n \"SUMMER20\"\n ]\n ],\n \"buyOperator\": \"OR\",\n \"stackingType\": \"STACKABLE\",\n \"level\": 1,\n \"termsAndConditions\": [\n {\n \"title\": \"Terms Applied\",\n \"description\": \"Items cannot be exchanged\"\n }\n ],\n \"promotionMessages\": [\n {\n \"title\": \"Buy 1 get 1 free\",\n \"message\": \"Offer valid at participating stores through September 5, 2023.\",\n \"pages\": [\n \"PDP\",\n \"Cart\"\n ],\n \"locales\": [\n \"en-CA\",\n \"fr-CA\"\n ]\n }\n ],\n \"proximityMessages\": [\n {\n \"threshold\": 1,\n \"localizedMessages\": [\n {\n \"locales\": [\n \"<string>\"\n ],\n \"message\": \"<string>\"\n }\n ]\n }\n ],\n \"shipmentMethodIds\": [\n \"1000001\"\n ],\n \"eligiblePriceList\": [\n 10000056\n ],\n \"note\": \"Independence day sale!\",\n \"limits\": [\n {\n \"kind\": \"ORDER\",\n \"value\": 2\n }\n ],\n \"additionalAttributes\": [\n {\n \"key\": \"type\",\n \"value\": \"Birthday\",\n \"attributeId\": 100000\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-site-context", "<x-site-context>")
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://live.copilot.fabric.inc/api-offers/coupon/create")
.header("x-site-context", "<x-site-context>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"CREATE COUPON\",\n \"promo\": [\n {\n \"discount\": [\n {\n \"unit\": \"%OFF\",\n \"value\": 10,\n \"ON\": {\n \"kind\": \"SKU\",\n \"value\": \"*\",\n \"quantity\": 2,\n \"includeOperator\": \"OR\",\n \"excludeOperator\": \"AND\"\n },\n \"discountId\": 1,\n \"autoAdd\": false,\n \"set\": []\n }\n ],\n \"targetProducts\": [\n {\n \"kind\": \"SKU\",\n \"value\": \"*\",\n \"operator\": \"IN\",\n \"discountId\": 1\n }\n ],\n \"condition\": [\n {\n \"conditions\": [\n {\n \"key\": \"SKU\",\n \"value\": \"*\",\n \"operator\": \"IN\"\n }\n ],\n \"includeOperator\": \"OR\",\n \"excludeOperator\": \"AND\",\n \"set\": \"A\"\n }\n ]\n }\n ],\n \"startDate\": \"2019-08-24T14:15:22Z\",\n \"endDate\": \"2019-08-25T14:15:22Z\",\n \"isExclusive\": true,\n \"type\": \"PRODUCT\",\n \"promoCodes\": [\n [\n \"SUMMER100\",\n \"SUMMER20\"\n ]\n ],\n \"buyOperator\": \"OR\",\n \"stackingType\": \"STACKABLE\",\n \"level\": 1,\n \"termsAndConditions\": [\n {\n \"title\": \"Terms Applied\",\n \"description\": \"Items cannot be exchanged\"\n }\n ],\n \"promotionMessages\": [\n {\n \"title\": \"Buy 1 get 1 free\",\n \"message\": \"Offer valid at participating stores through September 5, 2023.\",\n \"pages\": [\n \"PDP\",\n \"Cart\"\n ],\n \"locales\": [\n \"en-CA\",\n \"fr-CA\"\n ]\n }\n ],\n \"proximityMessages\": [\n {\n \"threshold\": 1,\n \"localizedMessages\": [\n {\n \"locales\": [\n \"<string>\"\n ],\n \"message\": \"<string>\"\n }\n ]\n }\n ],\n \"shipmentMethodIds\": [\n \"1000001\"\n ],\n \"eligiblePriceList\": [\n 10000056\n ],\n \"note\": \"Independence day sale!\",\n \"limits\": [\n {\n \"kind\": \"ORDER\",\n \"value\": 2\n }\n ],\n \"additionalAttributes\": [\n {\n \"key\": \"type\",\n \"value\": \"Birthday\",\n \"attributeId\": 100000\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://live.copilot.fabric.inc/api-offers/coupon/create")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-site-context"] = '<x-site-context>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"title\": \"CREATE COUPON\",\n \"promo\": [\n {\n \"discount\": [\n {\n \"unit\": \"%OFF\",\n \"value\": 10,\n \"ON\": {\n \"kind\": \"SKU\",\n \"value\": \"*\",\n \"quantity\": 2,\n \"includeOperator\": \"OR\",\n \"excludeOperator\": \"AND\"\n },\n \"discountId\": 1,\n \"autoAdd\": false,\n \"set\": []\n }\n ],\n \"targetProducts\": [\n {\n \"kind\": \"SKU\",\n \"value\": \"*\",\n \"operator\": \"IN\",\n \"discountId\": 1\n }\n ],\n \"condition\": [\n {\n \"conditions\": [\n {\n \"key\": \"SKU\",\n \"value\": \"*\",\n \"operator\": \"IN\"\n }\n ],\n \"includeOperator\": \"OR\",\n \"excludeOperator\": \"AND\",\n \"set\": \"A\"\n }\n ]\n }\n ],\n \"startDate\": \"2019-08-24T14:15:22Z\",\n \"endDate\": \"2019-08-25T14:15:22Z\",\n \"isExclusive\": true,\n \"type\": \"PRODUCT\",\n \"promoCodes\": [\n [\n \"SUMMER100\",\n \"SUMMER20\"\n ]\n ],\n \"buyOperator\": \"OR\",\n \"stackingType\": \"STACKABLE\",\n \"level\": 1,\n \"termsAndConditions\": [\n {\n \"title\": \"Terms Applied\",\n \"description\": \"Items cannot be exchanged\"\n }\n ],\n \"promotionMessages\": [\n {\n \"title\": \"Buy 1 get 1 free\",\n \"message\": \"Offer valid at participating stores through September 5, 2023.\",\n \"pages\": [\n \"PDP\",\n \"Cart\"\n ],\n \"locales\": [\n \"en-CA\",\n \"fr-CA\"\n ]\n }\n ],\n \"proximityMessages\": [\n {\n \"threshold\": 1,\n \"localizedMessages\": [\n {\n \"locales\": [\n \"<string>\"\n ],\n \"message\": \"<string>\"\n }\n ]\n }\n ],\n \"shipmentMethodIds\": [\n \"1000001\"\n ],\n \"eligiblePriceList\": [\n 10000056\n ],\n \"note\": \"Independence day sale!\",\n \"limits\": [\n {\n \"kind\": \"ORDER\",\n \"value\": 2\n }\n ],\n \"additionalAttributes\": [\n {\n \"key\": \"type\",\n \"value\": \"Birthday\",\n \"attributeId\": 100000\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"_id": "abcdefg1ee7ce20123456789",
"promoId": 100013,
"promoCodes": [
"SUMMER100",
"SUMMER20"
],
"state": "SCHEDULED",
"isImplicit": false,
"title": "CREATE PROMO",
"buyOperator": "OR",
"promo": [
{
"discount": [
{
"unit": "%OFF",
"value": 10,
"ON": {
"kind": "SKU",
"value": "*",
"quantity": 2,
"includeOperator": "OR",
"excludeOperator": "AND"
},
"discountId": 1,
"autoAdd": false,
"set": [
"A"
]
}
],
"targetProducts": [
{
"kind": "SKU",
"value": "*",
"operator": "IN",
"discountId": 1
}
],
"condition": [
"620d84a715f2d00001234567"
]
}
],
"startDate": "2019-08-24T14:15:22Z",
"endDate": "2019-08-25T14:15:22Z",
"isExclusive": true,
"type": "PRODUCT",
"stackingType": "STACKABLE",
"level": 1,
"termsAndConditions": [
{
"title": "Terms Applied",
"description": "Items cannot be exchanged"
}
],
"promotionMessages": [
{
"title": "Buy 1 get 1 free",
"message": "Offer valid at participating stores through September 5, 2023.",
"pages": [
"PDP",
"Cart"
],
"locales": [
"en-CA",
"fr-CA"
]
}
],
"proximityMessages": [
{
"threshold": 1,
"localizedMessages": [
{
"locales": [
"<string>"
],
"message": "<string>"
}
]
}
],
"shipmentMethodIds": [
1000001
],
"eligiblePriceList": [
10000056
],
"limits": [
{
"kind": "ORDER",
"value": 2
}
],
"note": "Independence day sale!",
"createdAt": "2019-08-20T14:15:22Z",
"updatedAt": "2019-08-20T14:15:22Z"
}{
"code": "DATE_ERROR",
"message": "The start date should be earlier than the end date and it should be a future date."
}{
"code": "INTERNAL_SERVER_ERROR",
"message": "Internal server error."
}Authorizations
Headers
The x-site-context header is a JSON object that contains information about the source you wish to pull from. The mandatory account is the 24 character identifier found in Copilot. The channel (Sales channel ID), stage (environment name), and date attributes can be used to further narrow the scope of your data source.
"{\"date\": \"2023-01-01T00:00:00.000Z\", \"channel\": 12, \"account\": \"1234abcd5678efgh9ijklmno\",\"stage\":\"production\"}"
Body
Promotion type.
Product: SKU promotion. Promotion or discount on SKUs based on the value mentioned in discount object
CART: Cart promotion. Promotion or discount on minimum cart value based on the ORDER_VALUE that is set in condition object
QUANTITY: Quantity promotion provides discounts based on the quantity requirement set in the promotion
BOGO: Buy One Get One promotion provides discounts based on the Buy conditions and Get discounts
SHIPPING: Shipping promotion provides discounts on the shipping cost
BUYGET: BuyGet promotion specifies the Buy conditions and Get discounts
SHIPPING: Shipping promotion provides discounts on the shipping cost
SPEND_GET: SpendGet promotion can specify the requirement of cart order value and the corresponding Get discounts
PRODUCT, CART, QUANTITY, BOGO, SHIPPING, BUYGET, SPEND_GET "PRODUCT"
Defines the rules for how a promotion can be combined with other promotions. This field determines whether a specific promotion can be applied in conjunction with other active promotions during a transaction or if it must be used exclusively. Possible values: - STACKABLE: This promotion can be combined with other stackable promotions, allowing multiple
discounts to be applied together. The order in which stackable promotions are applied
is determined by the level field, with promotions having a higher priority (lower numeric value)
being applied before those with a lower priority.
EXCLUSIVE: This promotion cannot be combined with any other promotions. Thelevelfield is used to determine which exclusive promotion will be evaluated and applied first. Once an exclusive promotion is applied, no other promotions can be used in the same transaction.TYPE_EXCLUSIVE: This promotion cannot be combined with other promotions of the same type. Thelevelfield is used to determine which promotion within the same type will be evaluated and applied first.UNIVERSAL: This promotion can be combined with any other promotions without restrictions. Universal promotions will be evaluated last. We don't need to definelevelfor this type.
STACKABLE, EXCLUSIVE, TYPE_EXCLUSIVE, UNIVERSAL "STACKABLE"
The promotion execution order. Promotion types are assigned default execution orders. Initial evaluation begins with level 1 promotions. The result of level 1 is used as the base price for level 2. Similarly, the result of level 2 becomes the base price for level 3, and so on.
1
Response
OK
Promotion status.
ACTIVE indicates that the promotion is applied to SKUs or items for which it is set as Active. Active promotions cannot be disabled.SCHEDULED indicates that the promotion is scheduled to be applied to SKUs or items based on the defined start date.DISABLED indicates that the promotion is set as disabled and is not in use. Only Disabled promotions can be enabled.EXPIRED indicates that the promotion is stopped by setting the expiration date. That is, the start date and end date as the current date. Only those promotions that are not expired can be enabled.
ACTIVE, SCHEDULED, DISABLED, EXPIRED "SCHEDULED"
Promotion type.
Product: SKU promotion. Promotion or discount on SKUs based on the value mentioned in discount object
CART: Cart promotion. Promotion or discount on cart amount based on the ORDER_VALUE that is set in condition object
QUANTITY: Quantity promotion provides discounts based on the quantity requirement set in the promotion
BOGO: Buy One Get One promotion provides discounts based on the Buy conditions and Get discounts
SHIPPING: Shipping promotion provides discounts on the shipping cost
BUYGET: BuyGet promotion specifies the Buy conditions and Get discounts
SPEND_GET: SpendGet promotion can specify the requirement of cart order value and the corresponding Get discounts
PRODUCT, CART, QUANTITY, BOGO, SHIPPING, BUYGET, SPEND_GET "PRODUCT"
Defines the rules for how a promotion can be combined with other promotions. This field determines whether a specific promotion can be applied in conjunction with other active promotions during a transaction or if it must be used exclusively. Possible values: - STACKABLE: This promotion can be combined with other stackable promotions, allowing multiple
discounts to be applied together. The order in which stackable promotions are applied
is determined by the level field, with promotions having a higher priority (lower numeric value)
being applied before those with a lower priority.
EXCLUSIVE: This promotion cannot be combined with any other promotions. Thelevelfield is used to determine which exclusive promotion will be evaluated and applied first. Once an exclusive promotion is applied, no other promotions can be used in the same transaction.TYPE_EXCLUSIVE: This promotion cannot be combined with other promotions of the same type. Thelevelfield is used to determine which promotion within the same type will be evaluated and applied first.UNIVERSAL: This promotion can be combined with any other promotions without restrictions. Universal promotions will be evaluated last. We don't need to definelevelfor this type.
STACKABLE, EXCLUSIVE, TYPE_EXCLUSIVE, UNIVERSAL "STACKABLE"
The promotion execution order. Promotion types are assigned default execution orders. Initial evaluation begins with level 1 promotions. The result of level 1 is used as the base price for level 2. Similarly, the result of level 2 becomes the base price for level 3, and so on.
1
Was this page helpful?
