Update a coupon - Fabric

Documentation Index

Fetch the complete documentation index at: /llms.txt

Use this file to discover all available pages before exploring further.

Skip to main content

Update a coupon

cURL

curl --request PUT \
  --url https://live.copilot.fabric.inc/api-offers/coupon/update/{couponId} \
  --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"\
            }\
          ],\
          "id": "akjhfds1239klhasdsa",\
          "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\
  ],
  "limits": [\
    {\
      "kind": "ORDER",\
      "value": 2\
    }\
  ],
  "note": "Independence day sale!",
  "additionalAttributes": [\
    {\
      "key": "type",\
      "value": "Birthday",\
      "attributeId": 100000\
    }\
  ]
}
'
import requests

url = "https://live.copilot.fabric.inc/api-offers/coupon/update/{couponId}"

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"\
                        }\
                    ],\
                    "id": "akjhfds1239klhasdsa",\
                    "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],
    "limits": [\
        {\
            "kind": "ORDER",\
            "value": 2\
        }\
    ],
    "note": "Independence day sale!",
    "additionalAttributes": [\
        {\
            "key": "type",\
            "value": "Birthday",\
            "attributeId": 100000\
        }\
    ]
}
headers = {
    "x-site-context": "<x-site-context>",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'PUT',
  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'}],\
            id: 'akjhfds1239klhasdsa',\
            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],
    limits: [{kind: 'ORDER', value: 2}],
    note: 'Independence day sale!',
    additionalAttributes: [{key: 'type', value: 'Birthday', attributeId: 100000}]
  })
};

fetch('https://live.copilot.fabric.inc/api-offers/coupon/update/{couponId}', 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/update/{couponId}",\
  CURLOPT_RETURNTRANSFER => true,\
  CURLOPT_ENCODING => "",\
  CURLOPT_MAXREDIRS => 10,\
  CURLOPT_TIMEOUT => 30,\
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,\
  CURLOPT_CUSTOMREQUEST => "PUT",\
  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'\
                                                                                                                                ]\
                                                                ],\
                                                                'id' => 'akjhfds1239klhasdsa',\
                                                                '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\
    ],\
    'limits' => [\
        [\
                'kind' => 'ORDER',\
                'value' => 2\
        ]\
    ],\
    'note' => 'Independence day sale!',\
    '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/update/{couponId}"

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          \"id\": \"akjhfds1239klhasdsa\",\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  \"limits\": [\n    {\n      \"kind\": \"ORDER\",\n      \"value\": 2\n    }\n  ],\n  \"note\": \"Independence day sale!\",\n  \"additionalAttributes\": [\n    {\n      \"key\": \"type\",\n      \"value\": \"Birthday\",\n      \"attributeId\": 100000\n    }\n  ]\n}")

req, _ := http.NewRequest("PUT", 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.put("https://live.copilot.fabric.inc/api-offers/coupon/update/{couponId}")
  .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          \"id\": \"akjhfds1239klhasdsa\",\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  \"limits\": [\n    {\n      \"kind\": \"ORDER\",\n      \"value\": 2\n    }\n  ],\n  \"note\": \"Independence day sale!\",\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/update/{couponId}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.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          \"id\": \"akjhfds1239klhasdsa\",\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  \"limits\": [\n    {\n      \"kind\": \"ORDER\",\n      \"value\": 2\n    }\n  ],\n  \"note\": \"Independence day sale!\",\n  \"additionalAttributes\": [\n    {\n      \"key\": \"type\",\n      \"value\": \"Birthday\",\n      \"attributeId\": 100000\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body

200

400

404

500

{
  "_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": []\
        }\
      ],\
      "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": "PROMO_NOT_FOUND",
  "message": "The promo code you entered doesn't exist."
}
{
  "code": "INTERNAL_SERVER_ERROR",
  "message": "Internal server error."
}

PUT

/

api-offers

/

coupon

/

update

/

{couponId}

Try it

Update a coupon

cURL

import requests

url = "https://live.copilot.fabric.inc/api-offers/coupon/update/{couponId}"

response = requests.put(url, json=payload, headers=headers)

print(response.text)
<?php

$curl = curl_init();

$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/update/{couponId}"

req, _ := http.NewRequest("PUT", 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))

}
require 'uri'
require 'net/http'

url = URI("https://live.copilot.fabric.inc/api-offers/coupon/update/{couponId}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

response = http.request(request)
puts response.read_body

200

400

404

500

{
  "code": "DATE_ERROR",
  "message": "The start date should be earlier than the end date and it should be a future date."
}
{
  "code": "PROMO_NOT_FOUND",
  "message": "The promo code you entered doesn't exist."
}
{
  "code": "INTERNAL_SERVER_ERROR",
  "message": "Internal server error."
}

Authorizations

Authorization

string

header

required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

x-site-context

string

required

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.

Example:

"{\"date\": \"2023-01-01T00:00:00.000Z\", \"channel\": 12, \"account\": \"1234abcd5678efgh9ijklmno\",\"stage\":\"production\"}"

Path Parameters

couponId

number

required

The ID of the coupon that needs to be updated.

Body

application/json

title

string

required

Promotion or coupon title

Required string length: 3 - 120

Example:

"CREATE COUPON"

promo

object[]

required

Showchild attributes

startDate

string

required

Start date of the promotion

Example:

"2019-08-24T14:15:22Z"

endDate

string

required

End date of the promotion

Example:

"2019-08-25T14:15:22Z"

isExclusive

boolean

required

A flag indicating whether a coupon can be stacked with an existing promotion. Set it to true to prevent the coupon from being applied to items that already have promotions and false to allow coupon to be applied with existing promotions.

Example:

true

type

enum

required

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

Available options:

PRODUCT,

CART,

QUANTITY,

BOGO,

SHIPPING,

BUYGET,

SPEND_GET

Example:

"PRODUCT"

promoCodes

string[]

required

A list of coupon codes that are applicable only for coupons. For coupons, the response includes promo codes associated with the coupon. For promotions, the response includes an empty array.

Minimum string length: 4

buyOperator

enum

default:OR

It is used to define operator between different Buy conditions (different conditions as mentioned in the condition object)

Available options:

AND,

OR

Example:

"OR"

stackingType

enum

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.

Available options:

STACKABLE,

EXCLUSIVE,

TYPE_EXCLUSIVE,

UNIVERSAL

Example:

"STACKABLE"

level

integer

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.

Example:

1

termsAndConditions

object[]

Showchild attributes

promotionMessages

object[]

Showchild attributes

proximityMessages

object[]

Showchild attributes

shipmentMethodIds

string[]

Required for Shipping type promo to provide eligible shipment Methods

eligiblePriceList

number[]

IDs of the price lists to which this promotion is applied

limits

object[]

Array of limits for the coupon to be applied

Showchild attributes

note

string

Promo note or description

Example:

"Independence day sale!"

additionalAttributes

object[]

A placeholder for additional attributes associated with promotions, in key-value pairs.

Showchild attributes

Response

200

application/json

OK

_id

string

A 24-character system-generated promotion ID.

Example:

"abcdefg1ee7ce20123456789"

promoId

number

A unique identifier of the promotion, for external use.

Example:

100013

promoCodes

string[]

Example:

["SUMMER100", "SUMMER20"]

state

enum

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.

Available options:

ACTIVE,

SCHEDULED,

DISABLED,

EXPIRED

Example:

"SCHEDULED"

isImplicit

boolean

A flag indicating whether an offer is applied automatically. Set it to true for promotions, which should be applied automatically and false for coupons, which must be applied explicitly.

Example:

false

title

string

Title of the promotion

Example:

"CREATE PROMO"

buyOperator

enum

default:OR

It is used to define operator between different Buy conditions (different conditions as mentioned in the condition object)

Available options:

AND,

OR

Example:

"OR"

promo

object[]

Showchild attributes

startDate

string

Start date of the promotion

Example:

"2019-08-24T14:15:22Z"

endDate

string

End date of the promotion

Example:

"2019-08-25T14:15:22Z"

isExclusive

boolean

A flag indicating whether a coupon can be stacked with an existing promotion. Set it to true to prevent the coupon from being applied to items that have promotions and false to allow coupon to be applied with existing promotions.

Example:

true

type

enum

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

Available options:

PRODUCT,

CART,

QUANTITY,

BOGO,

SHIPPING,

BUYGET,

SPEND_GET

Example:

"PRODUCT"

stackingType

enum

Available options:

STACKABLE,

EXCLUSIVE,

TYPE_EXCLUSIVE,

UNIVERSAL

Example:

"STACKABLE"

level

integer

Example:

1

termsAndConditions

object[]

Showchild attributes

promotionMessages

object[]

Showchild attributes

proximityMessages

object[]

Showchild attributes

shipmentMethodIds

string[]

Required for Shipping type promo to provide eligible shipment Methods

Shipping method IDs of the shipping methods to which promotion is applicable

eligiblePriceList

number[]

IDs of the price lists to which this promotion is applied

limits

object[]

Array of limits for the promotion to be applied

Showchild attributes

note

string

Promotion note or description

Example:

"Independence day sale!"

createdAt

string

Creation date of the record

Example:

"2019-08-20T14:15:22Z"

updatedAt

string

Last updated date of the record

Example:

"2019-08-20T14:15:22Z"

Was this page helpful?

YesNo

Overview Get a specific coupon

Ctrl+I

Assistant

Responses are generated using AI and may contain mistakes.