Skip to main content
POST
/
v1
/
vouchers
/
{code}
curl --request POST \
--url https://{cluster}.voucherify.io/v1/vouchers/{code} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-App-Id: <api-key>' \
--header 'X-App-Token: <api-key>' \
--data '{
"category": "New Customers",
"type": "DISCOUNT_VOUCHER",
"discount": {
"percent_off": 10,
"type": "PERCENT",
"effect": "APPLY_TO_ORDER"
},
"start_date": "2022-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_MBOEmHelKwvykVZ8JcT4TE5Kla5IMJyc",
"code": "welcome",
"campaign": null,
"campaign_id": null,
"category": "New Customers",
"type": "DISCOUNT_VOUCHER",
"discount": {
"type": "PERCENT",
"percent_off": 10,
"effect": "APPLY_TO_ORDER"
},
"gift": null,
"loyalty_card": null,
"start_date": "2022-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": "U2FsdGVkX1+by33CNzWu6xXjCrLKRr1+H9K3I9wOSa7idiHrMYJe0HlrWiy7INhaJf1BnaKJjLKcUC+4/hCbILtJ9lHXZWhewG5q5rmx29gK0IH2eRauw1qCZKIlXfqeGTG2T5ftPsEl1D4xf8W2MA==",
"url": "{{internalVoucherifyURL}}"
},
"barcode": {
"id": "U2FsdGVkX19wOdFeXYXZ4Xu22L0Ummk03Urz/ZTnXUFeHeehtK4L6RTvNgVeSR+McTZR4DYNLEGydZ+Fo2xEqqM1UWyl8Bx22Pi1CxghADOcy3bAvSca7EEPpvKrCY403UWUDvaO/OEAjvVoiEuaHA==",
"url": "{{internalVoucherifyURL}}"
}
},
"is_referral_code": false,
"created_at": "2022-02-17T09:05:34.668Z",
"updated_at": null,
"validation_rules_assignments": {
"object": "list",
"data_ref": "data",
"data": [
{
"id": "asgm_74F7QZoYbUoljwQO",
"rule_id": "val_4j7DCRm2IS59",
"related_object_id": "v_MBOEmHelKwvykVZ8JcT4TE5Kla5IMJyc",
"related_object_type": "voucher",
"created_at": "2022-02-17T09:05:34.642Z",
"object": "validation_rules_assignment"
}
],
"total": 1
},
"redemption": {
"quantity": 10,
"redeemed_quantity": 0,
"object": "list",
"url": "/v1/vouchers/welcome/redemptions?page=1&limit=10"
},
"publish": {
"object": "list",
"count": 0,
"url": "/v1/vouchers/welcome/publications?page=1&limit=10"
},
"object": "voucher"
}

Authorizations

X-App-Id
string
header
required
X-App-Token
string
header
required
Authorization
string
header
required

The access token received from the authorization server in the OAuth 2.0 flow.

Path Parameters

code
string
required

A unique code that identifies the voucher.

Example:

"2CpRCE2c"

Body

application/json

Specify the details of the voucher that you would like to create.

  • Create loyalty card
  • Create gift card
  • Create voucher in a discount campaign

Request body schema for POST v1/vouchers/{code}.

type
enum<string>
required

Defines the type of the voucher.

Available options:
LOYALTY_CARD
loyalty_card
object
required

Simplified loyalty card data.

campaign
string

Identifies the voucher's parent campaign using a unique campaign name.

Example:

"Gift Card Campaign"

campaign_id
string

Identifies the voucher's parent campaign using a unique campaign ID assigned by the Voucherify API.

Example:

"camp_FNYR4jhqZBM9xTptxDGgeNBV"

category
string

The name of the category that this voucher belongs to. Useful when listing vouchers with the List Vouchers endpoint.

category_id
string

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.

Example:

"cat_0b6152ce12414820dc"

start_date
string<date-time>

Start date defines when the code starts to be active. Activation timestamp is presented in the ISO 8601 format. Voucher is inactive before this date.

Example:

"2021-12-01T00:00:00.000Z"

expiration_date
string<date-time>

Expiration date defines when the code expires. Expiration timestamp is presented in the ISO 8601 format. Voucher is inactive after this date.

Example:

"2021-12-31T00:00:00.000Z"

validity_timeframe
object

Set recurrent time periods when the earning rule is valid. For example, valid for 1 hour every other day.start_date required when including the validity_timeframe.

validity_day_of_week
enum<integer>[]

Integer array corresponding to the particular days of the week in which the voucher is valid.

  • 0 Sunday
  • 1 Monday
  • 2 Tuesday
  • 3 Wednesday
  • 4 Thursday
  • 5 Friday
  • 6 Saturday
validity_hours
object

Determines the hours of validity, e.g. to create a happy hours scenario.

active
boolean

A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the start_date and expiration_date.

  • true indicates an active voucher
  • false indicates an inactive voucher
additional_info
string

An optional field to keep any extra textual information about the code such as a code description and details.

metadata
object

The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format.

validation_rules
string[]

Array containing the ID of the validation rule associated with the voucher.

redemption
object

Stores the quantity of redemptions that can be applied to the voucher.

Response

Returns a voucher object if the call succeeded.

Response body schema for POST v1/vouchers and /vouchers/{code} This is an object representing a voucher with categories and validation rules assignments. This is an object representing a voucher.

id
string

Assigned by the Voucherify API, identifies the voucher.

Example:

"v_mkZN9v7vjYUadXnHrMza8W5c34fE5KiV"

code
string

A code that identifies a voucher. Pattern can use all letters of the English alphabet, Arabic numerals, and special characters.

Example:

"WVPblOYX"

campaign
string

A unique campaign name, identifies the voucher's parent campaign.

Example:

"Gift Card Campaign"

campaign_id
string

Assigned by the Voucherify API, identifies the voucher's parent campaign.

Example:

"camp_FNYR4jhqZBM9xTptxDGgeNBV"

category
string

Tag defining the category that this voucher belongs to. Useful when listing vouchers using the List Vouchers endpoint.

category_id
string

Unique category ID assigned by Voucherify.

Example:

"cat_0bb343dee3cdb5ec0c"

type
enum<string>

Defines the type of the voucher.

Available options:
GIFT_VOUCHER,
DISCOUNT_VOUCHER,
LOYALTY_CARD
discount
object

Contains information about discount.

  • Amount
  • Unit
  • Unit Multiple
  • Percent
  • Fixed
gift
object

Object representing gift parameters. Child attributes are present only if type is GIFT_VOUCHER. Defaults to null.

loyalty_card
object

Object representing loyalty card parameters. Child attributes are present only if type is LOYALTY_CARD. Defaults to null.

start_date
string<date-time>

Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is inactive before this date.

Example:

"2021-12-01T00:00:00.000Z"

expiration_date
string<date-time>

Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is inactive after this date.

Example:

"2021-12-31T00:00:00.000Z"

validity_timeframe
object

Set recurrent time periods when the earning rule is valid. For example, valid for 1 hour every other day.start_date required when including the validity_timeframe.

validity_day_of_week
enum<integer>[]

Integer array corresponding to the particular days of the week in which the voucher is valid.

  • 0 Sunday
  • 1 Monday
  • 2 Tuesday
  • 3 Wednesday
  • 4 Thursday
  • 5 Friday
  • 6 Saturday
validity_hours
object

Determines the hours of validity, e.g. to create a happy hours scenario.

active
boolean | null

A flag to toggle the voucher on or off. You can disable a voucher even though it's within the active period defined by the start_date and expiration_date.

  • true indicates an active voucher
  • false indicates an inactive voucher
additional_info
string

An optional field to keep any extra textual information about the code such as a code description and details.

metadata
object

The metadata object stores all custom attributes assigned to the code. A set of key/value pairs that you can attach to a voucher object. It can be useful for storing additional information about the voucher in a structured format.

assets
object

Stores links to images of QR and barcode that correspond to an encrypted voucher code.

is_referral_code
boolean | null

Flag indicating whether this voucher is a referral code; true for campaign type REFERRAL_PROGRAM.

created_at
string<date-time>

Timestamp representing the date and time when the voucher was created. The value is shown in the ISO 8601 format.

Example:

"2021-12-22T10:13:06.487Z"

updated_at
string<date-time>

Timestamp representing the date and time when the voucher was last updated in ISO 8601 format.

Example:

"2021-12-22T10:14:45.316Z"

holder_id
string

Unique customer identifier of the redeemable holder. It equals to the customer ID assigned by Voucherify.

Example:

"cust_eWgXlBBiY6THFRJwX45Iakv4"

referrer_id
string

Unique identifier of the referring person.

Example:

"cust_Vzck5i8U3OhcEUFY6MKhN9Rv"

object
string
default:voucher

The type of the object represented by JSON. Default is voucher.

publish
object

Stores a summary of publication events: an event counter and endpoint to return details of each event. Publication is an assignment of a code to a customer, e.g. through a distribution.

redemption
object

Stores a summary of redemptions that have been applied to the voucher.

categories
Category · object[]

Contains details about the category.

validation_rules_assignments
object

List of Validation Rules Assignments

I