Skip to main content
POST
/
v1
/
campaigns
/
{campaignId}
/
vouchers
Add Vouchers to Campaign
curl --request POST \
  --url https://{cluster}.voucherify.io/v1/campaigns/{campaignId}/vouchers \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'X-App-Id: <api-key>' \
  --header 'X-App-Token: <api-key>' \
  --data '{
  "code": "<string>",
  "code_config": {
    "length": 123,
    "charset": "<string>",
    "prefix": "<string>",
    "postfix": "<string>",
    "pattern": "<string>",
    "initial_count": 123
  },
  "category": "<string>",
  "metadata": {},
  "redemption": {
    "quantity": 123
  },
  "additional_info": "<string>",
  "start_date": "2022-09-20T00:00:00.000Z",
  "expiration_date": "2022-09-30T00:00:00.000Z"
}'
{
  "id": "v_mkZN9v7vjYUadXnHrMza8W5c34fE5KiV",
  "code": "WVPblOYX",
  "campaign": "Gift Card Campaign",
  "campaign_id": "camp_FNYR4jhqZBM9xTptxDGgeNBV",
  "category": "<string>",
  "category_id": "cat_0bb343dee3cdb5ec0c",
  "type": "GIFT_VOUCHER",
  "discount": {
    "type": "AMOUNT",
    "amount_off": 123,
    "amount_off_formula": "<string>",
    "aggregated_amount_limit": 123,
    "effect": "APPLY_TO_ORDER",
    "is_dynamic": true
  },
  "gift": {
    "amount": 10000,
    "subtracted_amount": 123,
    "balance": 500,
    "effect": "APPLY_TO_ORDER"
  },
  "loyalty_card": {
    "points": 7000,
    "balance": 6970,
    "next_expiration_date": "2023-05-30",
    "next_expiration_points": 123,
    "pending_points": 123,
    "expired_points": 123,
    "subtracted_points": 123
  },
  "start_date": "2021-12-01T00:00:00.000Z",
  "expiration_date": "2021-12-31T00:00:00.000Z",
  "validity_timeframe": {
    "duration": "PT1H",
    "interval": "P2D"
  },
  "validity_day_of_week": [
    0
  ],
  "validity_hours": {
    "daily": [
      {
        "start_time": "12:00",
        "days_of_week": [
          0
        ],
        "expiration_time": "14:00"
      }
    ]
  },
  "active": true,
  "additional_info": "<string>",
  "metadata": {},
  "assets": {
    "qr": {
      "id": "U2FsdGVkX19ucFhvVmBVpVYG5KoswTsjSIaqoKg5L9ie4BK+t4pp7U7oFzjGJzj9q/bmuMOj9mEFiVKDMIkSaruKedMvHbKoPX5Sg+BaZk5QwXMf8k/OzSlOEVybpwSq+AiqPoNtjeuqtIgkDyvT6Q==",
      "url": "https://dev.dl.voucherify.io/api/v1/assets/qr/U2FsdGVkX19ucFhvVmBVpVYG5KoswTsjSIaqoKg5L9ie4BK%2Bt4pp7U7oFzjGJzj9q%2FbmuMOj9mEFiVKDMIkSaruKedMvHbKoPX5Sg%2BBaZk5QwXMf8k%2FOzSlOEVybpwSq%2BAiqPoNtjeuqtIgkDyvT6Q%3D%3D"
    },
    "barcode": {
      "id": "U2FsdGVkX19eJhGfWwUrH9+tulBkON+AnMktic+N6CVWzZ9+fHVxuVx22WakrzxiWXy0skuvvEHSeZIw9HlgyIJ+kJ1iPdUKpyENuNYJKzoZlO0mmTf6WQM6/pFs61apEn9SJx32ttCF6d3oxKISQQ==",
      "url": "https://dev.dl.voucherify.io/api/v1/assets/barcode/U2FsdGVkX19eJhGfWwUrH9%2BtulBkON%2BAnMktic%2BN6CVWzZ9%2BfHVxuVx22WakrzxiWXy0skuvvEHSeZIw9HlgyIJ%2BkJ1iPdUKpyENuNYJKzoZlO0mmTf6WQM6%2FpFs61apEn9SJx32ttCF6d3oxKISQQ%3D%3D"
    }
  },
  "is_referral_code": true,
  "created_at": "2021-12-22T10:13:06.487Z",
  "updated_at": "2021-12-22T10:14:45.316Z",
  "holder_id": "cust_eWgXlBBiY6THFRJwX45Iakv4",
  "referrer_id": "cust_Vzck5i8U3OhcEUFY6MKhN9Rv",
  "object": "voucher",
  "publish": {
    "object": "list",
    "count": 0,
    "url": "/v1/vouchers/WVPblOYX/publications?page=1&limit=10"
  },
  "redemption": {
    "quantity": 123,
    "redeemed_quantity": 1,
    "redeemed_points": 100000,
    "object": "list",
    "url": "/v1/vouchers/WVPblOYX/redemptions?page=1&limit=10"
  },
  "categories": [
    {
      "id": "<string>",
      "name": "<string>",
      "hierarchy": 1,
      "object": "category",
      "created_at": "2022-07-14T10:45:13.156Z",
      "updated_at": "2022-08-16T10:52:08.094Z"
    }
  ],
  "validation_rules_assignments": {
    "object": "list",
    "data_ref": "data",
    "data": [
      {
        "id": "asgm_LnY1g7UNFA9KyDrD",
        "rule_id": "val_3gPNA6SnH4ae",
        "related_object_id": "camp_CZOnEGiZfwIKWmSjhIoIT7Ol",
        "related_object_type": "campaign",
        "object": "validation_rules_assignment",
        "validation_status": "PARTIALLY_VALID",
        "validation_omitted_rules": [
          "1"
        ]
      }
    ],
    "total": 1
  }
}

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

campaignId
string
required

The campaign ID or name of the campaign to which voucher(s) will be added. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value.

Example:

"camp_rRsfatlwN7unSeUIJDCYedal"

Query Parameters

vouchers_count
integer

Number of vouchers that should be added.

Body

application/json

Specify the voucher parameters that you would like to overwrite.

Request body schema for POST v1/campaigns/{campaignId}/vouchers.

code
string

Unique voucher code.

code_config
object

Contains information about the config used for the voucher code. Defines the code's pattern (prefix, postfix, length, charset, etc).

category
string

The category assigned to the campaign. Either pass this parameter OR the category_id.

metadata
object

The metadata object stores all custom attributes assigned to the voucher. 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.

redemption
object

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

additional_info
string

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

start_date
string<date-time>

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

Example:

"2022-09-20T00:00:00.000Z"

expiration_date
string<date-time>

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

Example:

"2022-09-30T00:00:00.000Z"

Response

Returns a voucher object if the call succeeded for a voucher count of 1.

Response body schema for POST v1/campaigns/{campaignId}/vouchers/{code} and POST v1/campaigns/{campaignId}/vouchers. 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