Create Promotion codes
note
When a promotion expires, the promotion codes attached to that promotion automatically become invalid, though they are not deleted.
Should you re-enable the expired promotion, the promotion codes attached to that promotion are deleted.
POST
Create Promotion Codes
https://api.moltin.com/v2/promotions/:id/codes
Path Parameters:
Name | Required | Type | Description |
---|---|---|---|
id | Required | string | The unique promotion identifier. |
Headers:
Name | Required | Type | Description |
---|---|---|---|
Authorization | Required | string | The Bearer token to grant access to the API. |
Body:
Name | Required | Type | Description |
---|---|---|---|
type | Required | string | promotion_codes |
codes | Required | array | An array of objects. |
codes[].code | Required | string | A string to use as a code for the promotion. |
codes[].uses | Optional | integer | Number of times code can be used. |
codes[].user | Optional | string | A string that can be used to identify a user. You can use the Customer object ID or an array of Customer object IDs. For more information, see Create a customer. Additionally, you could pass any identifying string to the promotions service that identifies a user. |
201 Created
{
"data": {
"type": "promotion",
"id": "7005b249-300b-4cf6-964e-e663278af218",
"name": "Promo #1",
"description": "Initial Promotion",
"enabled": true,
"promotion_type": "fixed_discount",
"schema": {
"currencies": [
{
"currency": "USD",
"amount": 900
},
{
"currency": "GBP",
"amount": 1100
}
]
},
"start": "2017-11-13T00:00:00Z",
"end": "2019-11-13T00:00:00Z",
"created_at": "2018-05-10T15:25:21.164Z",
"updated_at": "2018-05-10T15:26:18.203Z"
}
}
curl -X POST https://api.moltin.com/v2/promotions/:id/codes \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d $'{
"data":{
"type":"promotion_codes",
"codes": [
{"code":"ZXY_CBA"},
{"code":"ABC_XYZ"}
]
}
}'