curl --request POST \
--url https://{cluster}.voucherify.io/v1/vouchers \
--header 'Content-Type: application/json' \
--header 'X-App-Id: <api-key>' \
--header 'X-App-Token: <api-key>' \
--data '
{
"category": "New Customers",
"code": "NEW-WELCOME-COUPON",
"type": "DISCOUNT_VOUCHER",
"campaign_id": "camp_Y6dLsYIZloGqP8izufXY6SSJ",
"discount": {
"percent_off": 10,
"type": "PERCENT",
"effect": "APPLY_TO_ORDER"
},
"start_date": "2016-01-01T00:00:00Z",
"expiration_date": "2022-12-31T23:59:59Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P2D"
},
"validity_day_of_week": [
1,
2,
3,
4,
5
],
"active": false,
"additional_info": "This voucher will remain inactive until enabled.",
"redemption": {
"quantity": 10
},
"metadata": {
"test": true,
"locale": "de-en"
},
"validation_rules": [
"val_4j7DCRm2IS59"
]
}
'{
"id": "v_YJYfeKoR0XAGIvaM7k51wTbDjU4WIpC5",
"code": "NEW-WELCOME-COUPON",
"campaign": "Bug fix",
"campaign_id": "camp_Y6dLsYIZloGqP8izufXY6SSJ",
"category": "New Customers",
"type": "DISCOUNT_VOUCHER",
"discount": {
"type": "PERCENT",
"percent_off": 10,
"effect": "APPLY_TO_ORDER"
},
"gift": null,
"loyalty_card": null,
"start_date": "2016-01-01T00:00:00.000Z",
"expiration_date": "2022-12-31T23:59:59.000Z",
"validity_timeframe": {
"interval": "P2D",
"duration": "PT1H"
},
"validity_day_of_week": [
1,
2,
3,
4,
5
],
"active": false,
"additional_info": "This voucher will remain inactive until enabled.",
"metadata": {
"test": true,
"locale": "de-en"
},
"assets": {
"qr": {
"id": "U2FsdGVkX180g6GhUA0kT47tHGvZ5thjCgY5nbsPtiecixkkEznFVg2v3SDG9dpCbXR6BSUdM/d78Wm/zru1ybT4+AQ2X0JnEy86N7TZ/aoezZORjcBRUfyVM/scUUF/vmD4Ezn+Elp2+V9AFcAXN/WthaRMl9e7xvEeIEQ5nao=",
"url": "{{internalVoucherifyURL}}"
},
"barcode": {
"id": "U2FsdGVkX1/AynivxYCEIxfTnf3A1lO0xsNihOlbUMo6Y6873LQ2qpmkk90aUFnaFKd7pVumcirRweblzGVSxy24Phhd174VSPaLxxmSKp0FPv0dRos/XWBg8zu0Kta0pA/yvFK3WWGlNoPPPnvEhVWKKzOr09Gj94SMrr+TGlI=",
"url": "{{internalVoucherifyURL}}"
}
},
"is_referral_code": false,
"created_at": "2022-02-17T07:14:40.096Z",
"updated_at": null,
"validation_rules_assignments": {
"object": "list",
"data_ref": "data",
"data": [
{
"id": "asgm_COu5PJAsWmAwuCqR",
"rule_id": "val_4j7DCRm2IS59",
"related_object_id": "v_YJYfeKoR0XAGIvaM7k51wTbDjU4WIpC5",
"related_object_type": "voucher",
"created_at": "2022-02-17T07:14:40.280Z",
"object": "validation_rules_assignment"
}
],
"total": 1
},
"redemption": {
"quantity": 10,
"redeemed_quantity": 0,
"object": "list",
"url": "/v1/vouchers/NEW-WELCOME-COUPON/redemptions?page=1&limit=10"
},
"publish": {
"object": "list",
"count": 0,
"url": "/v1/vouchers/NEW-WELCOME-COUPON/publications?page=1&limit=10"
},
"object": "voucher"
}Generate Random Code
Create a generic (standalone) vouchers. You can choose to create a GIFT_VOUCHER, a DISCOUNT_VOUCHER, or a legacy LOYALTY_CARD.
When you create a new voucher, you can specify a type to create it.
Creating a new voucher will create a new generic (standalone) vouchers if no campaign name or campaign_id is provided. However, if an ID or name of a campaign with the type set to STANDALONE is provided, the voucher will be added to such campaign. In case of the loyalty card, a campaign name is required.
You can optionally use the code parameter to define a specific code or the code_config parameter to design rules for Voucherify API to create a random code. If neither of the two parameters are passed, then a random code is generated by the Voucherify API.
This method will return an error when trying to create a voucher that already exists.
Generic (standalone) vouchers created through the Voucherify dashboard always create a campaign for that voucher. The vouchers created with POST Create voucher and POST Generate random code endpoints do not have a campaign attached, so the values for campaign and campaign_id are null.
To create a generic (standalone) voucher with a "type": "STANDALONE", use the POST Create campaign endpoint.
curl --request POST \
--url https://{cluster}.voucherify.io/v1/vouchers \
--header 'Content-Type: application/json' \
--header 'X-App-Id: <api-key>' \
--header 'X-App-Token: <api-key>' \
--data '
{
"category": "New Customers",
"code": "NEW-WELCOME-COUPON",
"type": "DISCOUNT_VOUCHER",
"campaign_id": "camp_Y6dLsYIZloGqP8izufXY6SSJ",
"discount": {
"percent_off": 10,
"type": "PERCENT",
"effect": "APPLY_TO_ORDER"
},
"start_date": "2016-01-01T00:00:00Z",
"expiration_date": "2022-12-31T23:59:59Z",
"validity_timeframe": {
"duration": "PT1H",
"interval": "P2D"
},
"validity_day_of_week": [
1,
2,
3,
4,
5
],
"active": false,
"additional_info": "This voucher will remain inactive until enabled.",
"redemption": {
"quantity": 10
},
"metadata": {
"test": true,
"locale": "de-en"
},
"validation_rules": [
"val_4j7DCRm2IS59"
]
}
'{
"id": "v_YJYfeKoR0XAGIvaM7k51wTbDjU4WIpC5",
"code": "NEW-WELCOME-COUPON",
"campaign": "Bug fix",
"campaign_id": "camp_Y6dLsYIZloGqP8izufXY6SSJ",
"category": "New Customers",
"type": "DISCOUNT_VOUCHER",
"discount": {
"type": "PERCENT",
"percent_off": 10,
"effect": "APPLY_TO_ORDER"
},
"gift": null,
"loyalty_card": null,
"start_date": "2016-01-01T00:00:00.000Z",
"expiration_date": "2022-12-31T23:59:59.000Z",
"validity_timeframe": {
"interval": "P2D",
"duration": "PT1H"
},
"validity_day_of_week": [
1,
2,
3,
4,
5
],
"active": false,
"additional_info": "This voucher will remain inactive until enabled.",
"metadata": {
"test": true,
"locale": "de-en"
},
"assets": {
"qr": {
"id": "U2FsdGVkX180g6GhUA0kT47tHGvZ5thjCgY5nbsPtiecixkkEznFVg2v3SDG9dpCbXR6BSUdM/d78Wm/zru1ybT4+AQ2X0JnEy86N7TZ/aoezZORjcBRUfyVM/scUUF/vmD4Ezn+Elp2+V9AFcAXN/WthaRMl9e7xvEeIEQ5nao=",
"url": "{{internalVoucherifyURL}}"
},
"barcode": {
"id": "U2FsdGVkX1/AynivxYCEIxfTnf3A1lO0xsNihOlbUMo6Y6873LQ2qpmkk90aUFnaFKd7pVumcirRweblzGVSxy24Phhd174VSPaLxxmSKp0FPv0dRos/XWBg8zu0Kta0pA/yvFK3WWGlNoPPPnvEhVWKKzOr09Gj94SMrr+TGlI=",
"url": "{{internalVoucherifyURL}}"
}
},
"is_referral_code": false,
"created_at": "2022-02-17T07:14:40.096Z",
"updated_at": null,
"validation_rules_assignments": {
"object": "list",
"data_ref": "data",
"data": [
{
"id": "asgm_COu5PJAsWmAwuCqR",
"rule_id": "val_4j7DCRm2IS59",
"related_object_id": "v_YJYfeKoR0XAGIvaM7k51wTbDjU4WIpC5",
"related_object_type": "voucher",
"created_at": "2022-02-17T07:14:40.280Z",
"object": "validation_rules_assignment"
}
],
"total": 1
},
"redemption": {
"quantity": 10,
"redeemed_quantity": 0,
"object": "list",
"url": "/v1/vouchers/NEW-WELCOME-COUPON/redemptions?page=1&limit=10"
},
"publish": {
"object": "list",
"count": 0,
"url": "/v1/vouchers/NEW-WELCOME-COUPON/publications?page=1&limit=10"
},
"object": "voucher"
}Authorizations
Scopes
Body
Specify the details of the voucher that you would like to create.
- Create loyalty card with specific code
- Create loyalty card with code config
- Create gift card with specific code
- Create gift card with code config
- Create voucher in a discount campaign with specific code
- Create voucher in a discount campaign with code config
Request body schema for POST v1/vouchers.
Code that identifies a voucher. The pattern can use all the letters of the English alphabet, Arabic numerals, and special characters. Pass this attribute in the request body to create a distinct code. Otherwise, either use the code_config object to set the rules that the Voucherify API will use to create a random code, or don't pass any code and Voucherify will generate a random code.
"WVPblOYX"
The name of the category that this voucher belongs to. Useful when listing vouchers with the List Vouchers endpoint.
Unique identifier assigned by Voucherify to the name of the category that this voucher belongs to. Useful when listing vouchers with the List Vouchers endpoint.
"cat_0b6152ce12414820dc"
Response
Returns a voucher object if the call succeeded.
Response body schema for POST v1/vouchers and /vouchers/{code}

