> ## Documentation Index
>
> Fetch the complete documentation index at: [/llms.txt](https://developer.fabric.inc/llms.txt)
>
> Use this file to discover all available pages before exploring further.

[Skip to main content](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#content-area)

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

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#authorization-authorization)

Authorization

string

header

required

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

#### Headers

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#parameter-x-site-context)

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

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#parameter-coupon-id)

couponId

number

required

The ID of the coupon that needs to be updated.

#### Body

application/json

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-title)

title

string

required

Promotion or coupon title

Required string length: `3 - 120`

Example:

`"CREATE COUPON"`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-promo)

promo

object\[\]

required

Showchild attributes

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-start-date)

startDate

string<date-time>

required

Start date of the promotion

Example:

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

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-end-date)

endDate

string<date-time>

required

End date of the promotion

Example:

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

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-is-exclusive)

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`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-type)

type

enum<string>

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"`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-promo-codes)

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`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-buy-operator)

buyOperator

enum<string>

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"`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-stacking-type)

stackingType

enum<string>

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. The `level` field 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.
The `level` field 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 define `level` for this type.

Available options:

`STACKABLE`,

`EXCLUSIVE`,

`TYPE_EXCLUSIVE`,

`UNIVERSAL`

Example:

`"STACKABLE"`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-level)

level

integer<int32>

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`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-terms-and-conditions)

termsAndConditions

object\[\]

Showchild attributes

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-promotion-messages)

promotionMessages

object\[\]

Showchild attributes

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-proximity-messages)

proximityMessages

object\[\]

Showchild attributes

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-shipment-method-ids)

shipmentMethodIds

string\[\]

Required for Shipping type promo to provide eligible shipment Methods

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-eligible-price-list)

eligiblePriceList

number\[\]

IDs of the price lists to which this promotion is applied

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-limits)

limits

object\[\]

Array of limits for the coupon to be applied

Showchild attributes

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-note)

note

string

Promo note or description

Example:

`"Independence day sale!"`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#body-additional-attributes)

additionalAttributes

object\[\]

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

Showchild attributes

#### Response

200

application/json

OK

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-id)

\_id

string

A 24-character system-generated promotion ID.

Example:

`"abcdefg1ee7ce20123456789"`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-promo-id)

promoId

number

A unique identifier of the promotion, for external use.

Example:

`100013`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-promo-codes)

promoCodes

string\[\]

Example:

```
["SUMMER100", "SUMMER20"]
```

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-state)

state

enum<string>

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"`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-is-implicit)

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`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-title)

title

string

Title of the promotion

Example:

`"CREATE PROMO"`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-buy-operator)

buyOperator

enum<string>

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"`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-promo)

promo

object\[\]

Showchild attributes

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-start-date)

startDate

string<date-time>

Start date of the promotion

Example:

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

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-end-date)

endDate

string<date-time>

End date of the promotion

Example:

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

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-is-exclusive)

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`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-type)

type

enum<string>

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"`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-stacking-type)

stackingType

enum<string>

Available options:

`STACKABLE`,

`EXCLUSIVE`,

`TYPE_EXCLUSIVE`,

`UNIVERSAL`

Example:

`"STACKABLE"`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-level)

level

integer<int32>

Example:

`1`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-terms-and-conditions)

termsAndConditions

object\[\]

Showchild attributes

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-promotion-messages)

promotionMessages

object\[\]

Showchild attributes

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-proximity-messages)

proximityMessages

object\[\]

Showchild attributes

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-shipment-method-ids)

shipmentMethodIds

string\[\]

Required for Shipping type promo to provide eligible shipment Methods

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

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-eligible-price-list)

eligiblePriceList

number\[\]

IDs of the price lists to which this promotion is applied

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-limits)

limits

object\[\]

Array of limits for the promotion to be applied

Showchild attributes

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-note)

note

string

Promotion note or description

Example:

`"Independence day sale!"`

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-created-at)

createdAt

string<date-time>

Creation date of the record

Example:

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

[​](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/update-a-coupon#response-updated-at)

updatedAt

string<date-time>

Last updated date of the record

Example:

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

Was this page helpful?

YesNo

[Overview](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/overview) [Get a specific coupon](https://developer.fabric.inc/v2/api-reference/offers-v2/coupon/get-a-specific-coupon)

Ctrl+I

Assistant

Responses are generated using AI and may contain mistakes.
