curl --request POST \
--url https://{cluster}.voucherify.io/v1/publications \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-App-Id: <api-key>' \
--header 'X-App-Token: <api-key>' \
--data '
{
"campaign": {
"name": "campaign-name"
},
"customer": {
"source_id": "source-id",
"Name": "Customer Name",
"email": "customer email"
},
"voucher": "voucher-code",
"metadata": {
"key": "value"
}
}
'{
"id": "pub_ocaXCa023ayJ3WL1ARxUeKgIvg3JcEGh",
"object": "publication",
"created_at": "2022-09-30T16:30:32.924Z",
"customer_id": "cust_BB6F97yf0XqCe7hxVUV7M4sS",
"tracking_id": "pub_source_customer_5",
"metadata": {
"year": 2022
},
"channel": "myown",
"source_id": "publication_source_ID_10",
"result": "SUCCESS",
"customer": {
"id": "cust_BB6F97yf0XqCe7hxVUV7M4sS",
"name": "Bob Jones",
"email": "bob.smith@email.com",
"source_id": "pub_source_customer_5",
"metadata": {
"lang": "en",
"test": true
},
"object": "customer"
},
"voucher": {
"id": "v_6Hy5FdNlu3dP65fJu5BgXma31Sl3rgkf",
"code": "cEsMn0uA",
"campaign": "Test - Discount Effect - Amount - Items",
"campaign_id": "camp_dphuwqH7BOVkgh4JmpDtS32l",
"category": null,
"category_id": null,
"type": "DISCOUNT_VOUCHER",
"discount": {
"type": "AMOUNT",
"amount_off": 300,
"effect": "APPLY_TO_ITEMS"
},
"gift": null,
"loyalty_card": null,
"start_date": null,
"expiration_date": null,
"validity_timeframe": null,
"validity_day_of_week": null,
"active": true,
"additional_info": null,
"metadata": {},
"assets": {
"qr": {
"id": "U2FsdGVkX188XVmOotyCyR2j3G8sJR8HzS3DQ+6J1OElPWSmjlEnthuJc7rkc7WIVxjT4pTl1JVVkHEuGXNXdzRik11H8S18HQeQFJFiuwLZ2mzEC2zZitEinyUxtZwhnEHoi0eGAgYCG7iVMNuOQA==",
"url": "{{internalVoucherifyURL}}"
},
"barcode": {
"id": "U2FsdGVkX18wDd9CcLM0Ef7aBfUSXZUoCQpuNpk4CHGOipbn+wFkfzcIZGBtUlxrI2KsXciCqF+c93AKzsymq5Yw8eEAFF/FK5f94z4/sgzaLDvyBmPCXHuS11Ew9S4ZEMjdTkUJftER2IlxWaCARA==",
"url": "{{internalVoucherifyURL}}"
}
},
"is_referral_code": false,
"created_at": "2022-09-30T16:30:32.956Z",
"updated_at": null,
"holder_id": "cust_BB6F97yf0XqCe7hxVUV7M4sS",
"redemption": {
"quantity": 1,
"redeemed_quantity": 0,
"object": "list",
"url": "/v1/vouchers/cEsMn0uA/redemptions?page=1&limit=10"
},
"publish": {
"object": "list",
"count": 1,
"url": "/v1/vouchers/cEsMn0uA/publications?page=1&limit=10"
},
"object": "voucher"
},
"vouchers_id": [
"v_6Hy5FdNlu3dP65fJu5BgXma31Sl3rgkf"
]
}This method selects vouchers that are suitable for publication, adds a publish entry and returns the publication.
A voucher is suitable for publication when it’s active and hasn’t been published yet.
🚧 Clearly define the source of the voucher
You must clearly define which source you want to publish the voucher code from. It can either be a code from a campaign or a specific voucher identified by a code.
🚧 Publish multiple vouchers In case you want to publish multiple vouchers within a single publication, you need to specify the campaign name and number of vouchers you want to publish.
📘 Auto-update campaign
In case you want to ensure the number of publishable codes increases automatically with the number of customers, you should use an auto-update campaign.
curl --request POST \
--url https://{cluster}.voucherify.io/v1/publications \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-App-Id: <api-key>' \
--header 'X-App-Token: <api-key>' \
--data '
{
"campaign": {
"name": "campaign-name"
},
"customer": {
"source_id": "source-id",
"Name": "Customer Name",
"email": "customer email"
},
"voucher": "voucher-code",
"metadata": {
"key": "value"
}
}
'{
"id": "pub_ocaXCa023ayJ3WL1ARxUeKgIvg3JcEGh",
"object": "publication",
"created_at": "2022-09-30T16:30:32.924Z",
"customer_id": "cust_BB6F97yf0XqCe7hxVUV7M4sS",
"tracking_id": "pub_source_customer_5",
"metadata": {
"year": 2022
},
"channel": "myown",
"source_id": "publication_source_ID_10",
"result": "SUCCESS",
"customer": {
"id": "cust_BB6F97yf0XqCe7hxVUV7M4sS",
"name": "Bob Jones",
"email": "bob.smith@email.com",
"source_id": "pub_source_customer_5",
"metadata": {
"lang": "en",
"test": true
},
"object": "customer"
},
"voucher": {
"id": "v_6Hy5FdNlu3dP65fJu5BgXma31Sl3rgkf",
"code": "cEsMn0uA",
"campaign": "Test - Discount Effect - Amount - Items",
"campaign_id": "camp_dphuwqH7BOVkgh4JmpDtS32l",
"category": null,
"category_id": null,
"type": "DISCOUNT_VOUCHER",
"discount": {
"type": "AMOUNT",
"amount_off": 300,
"effect": "APPLY_TO_ITEMS"
},
"gift": null,
"loyalty_card": null,
"start_date": null,
"expiration_date": null,
"validity_timeframe": null,
"validity_day_of_week": null,
"active": true,
"additional_info": null,
"metadata": {},
"assets": {
"qr": {
"id": "U2FsdGVkX188XVmOotyCyR2j3G8sJR8HzS3DQ+6J1OElPWSmjlEnthuJc7rkc7WIVxjT4pTl1JVVkHEuGXNXdzRik11H8S18HQeQFJFiuwLZ2mzEC2zZitEinyUxtZwhnEHoi0eGAgYCG7iVMNuOQA==",
"url": "{{internalVoucherifyURL}}"
},
"barcode": {
"id": "U2FsdGVkX18wDd9CcLM0Ef7aBfUSXZUoCQpuNpk4CHGOipbn+wFkfzcIZGBtUlxrI2KsXciCqF+c93AKzsymq5Yw8eEAFF/FK5f94z4/sgzaLDvyBmPCXHuS11Ew9S4ZEMjdTkUJftER2IlxWaCARA==",
"url": "{{internalVoucherifyURL}}"
}
},
"is_referral_code": false,
"created_at": "2022-09-30T16:30:32.956Z",
"updated_at": null,
"holder_id": "cust_BB6F97yf0XqCe7hxVUV7M4sS",
"redemption": {
"quantity": 1,
"redeemed_quantity": 0,
"object": "list",
"url": "/v1/vouchers/cEsMn0uA/redemptions?page=1&limit=10"
},
"publish": {
"object": "list",
"count": 1,
"url": "/v1/vouchers/cEsMn0uA/publications?page=1&limit=10"
},
"object": "voucher"
},
"vouchers_id": [
"v_6Hy5FdNlu3dP65fJu5BgXma31Sl3rgkf"
]
}The access token received from the authorization server in the OAuth 2.0 flow.
Through this flag, you can control if a particular person gets only one and always the same code even if the app sends multiple publication requests. It means that if you have a referral program, a referrer is assigned only to one code if an integration sends publication requests more than once for the same customer.
Specify the publication parameters.
Request body schema for POST v1/publications.
Code of the voucher being published.
Contains information about the customer to whom the publication was directed.
Show child attributes
The ID of an existing customer.
A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored.
Customer's first and last name.
An arbitrary string that you can attach to a customer object.
Customer's email address.
Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel.
Deprecated. Customer's birthdate; format YYYY-MM-DD.
Customer's birthdate; format YYYY-MM-DD.
A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments.
The merchant's publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service.
If source_id is provided only 1 voucher can be published per request.
The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format.
Specify the distribution channel.
Returns a publication object if a valid identifier was provided.
Response body schema for POST v1/publication and GET v1/publications/create.
Response body schema for POST v1/publication and GET v1/publications/create.
Unique publication ID, assigned by Voucherify.
"pub_BbjAXnmm8e0SIm3zG8qvvFCP0KuLywtp"
The type of the object represented by the JSON. This object stores information about the publication.
publication Timestamp representing the date and time when the publication was created. The value is shown in the ISO 8601 format.
"2022-09-23T09:57:00.434Z"
Unique customer ID of the customer receiving the publication.
"cust_eWgXlBBiY6THFRJwX45Iakv4"
The metadata object stores all custom attributes assigned to the publication. A set of key/value pairs that you can attach to a publication object. It can be useful for storing additional information about the publication in a structured format.
How the publication was originated. It can be your own custom channel or an example value provided here.
API The merchant's publication ID if it is different from the Voucherify publication ID. It's an optional tracking identifier of a publication. It is really useful in case of an integration between multiple systems. It can be a publication ID from a CRM system, database or 3rd-party service.
Status of the publication attempt.
SUCCESS Show child attributes
Show child attributes
Show child attributes
Total number of redemptions made by the customer.
Total number of redemptions that failed.
Total number of redemptions that succeeded.
Total number of redemptions that were rolled back for the customer.
Total number of redemption rollbacks that failed.
Total number of redemption rollbacks that succeeded.
Summary of gift card credits.
Show child attributes
Total amount of gift card credits redeemed by customer. The value is multiplied by 100 to represent 2 decimal places. For example 10000 cents for $100.00.
Remaining gift card balance across all gift cards. The value is multiplied by 100 to represent 2 decimal places. For example 10000 cents for $100.00.
Summary of loyalty points.
Lists details about orders related to the customer. Lists only data for orders with the PAID or FULFILLED status. Data from orders with a CREATED or CANCELED status are not included. The data is updated also when an order changes status.
Show child attributes
The total amount spent by the customer. The value is multiplied by 100 to represent 2 decimal places. For example 10000 cents for $100.00.
Total number of orders made by the customer.
Average amount spent on orders. total_amount ÷ total_count. The value is multiplied by 100 to represent 2 decimal places. For example 10000 cents for $100.00.
Amount spent on last order. The value is multiplied by 100 to represent 2 decimal places. For example 10000 cents for $100.00.
Timestamp representing the date and time of the customer's last order in ISO 8601 format.
"2022-08-30T11:51:08.029Z"
Show child attributes
Customer's loyalty points minus expired for all loyalty cards which the customer has.
Total number of customers referred by the customer.
Contains campaigns with details about point balances and how many customers were referred by the customer.
Show child attributes
Contains details about the point balances left on loyalty cards and the number of referred customers in each campaign.
Show child attributes
Remaining point balance in campaign.
Customer's loyalty tier within the campaign.
"ltr_UJ5Q54Q0OvEhua87Qfv2Ki5x"
Number of customers referred by the customer in campaign.
Summary of customer's referrals, in this case, the customer being the referee, i.e. information about the source of referrals and number of times the customer was referred by other customers.
Show child attributes
Total number of times this customer received a referral, i.e. was referred by another customer.
Contains an array of campaigns that served as the source of a referral for the customer.
Show child attributes
Unique campaign ID, assigned by Voucherify.
"camp_rRsfatlwN7unSeUIJDCYedal"
Unique referrer ID, assigned by Voucherify. This is the customer ID of a customer that is referring this customer.
"cust_sehkNIi8Uq2qQuRqSr7xn4Zi"
Related object id
"r_0b9d4cc4aa164dd073"
Related object type, i.e. redemption.
Timestamp representing the date and time when the customer was referred in ISO 8601 format.
"2022-08-30T10:19:39.196Z"
The type of the object represented by JSON.
customer The ID of an existing customer that will be linked to redemption in this request.
A unique identifier of the customer who validates a voucher. It can be a customer ID or email from a CRM system, database, or a third-party service. If you also pass a customer ID (unique ID assigned by Voucherify), the source ID will be ignored.
Object used to store system metadata information.
Timestamp representing the date and time when the customer was created. The value is shown in the ISO 8601 format.
"2022-08-30T06:32:07.380Z"
Timestamp representing the date and time when the customer was updated. The value is shown in the ISO 8601 format.
"2022-08-31T06:32:07.380Z"
Customer's first and last name.
An arbitrary string that you can attach to a customer object.
Customer's email address.
Customer's phone number. This parameter is mandatory when you try to send out codes to customers via an SMS channel.
Deprecated. Customer's birthdate; format YYYY-MM-DD.
Customer's birthdate; format YYYY-MM-DD.
A set of custom key/value pairs that you can attach to a customer. The metadata object stores all custom attributes assigned to the customer. It can be useful for storing additional information about the customer in a structured format. This metadata can be used for validating whether the customer qualifies for a discount or it can be used in building customer segments.
Contains the unique internal voucher ID that was assigned by Voucherify.
This is an object representing a voucher with categories and validation rules assignments.
Show child attributes
Assigned by the Voucherify API, identifies the voucher.
"v_mkZN9v7vjYUadXnHrMza8W5c34fE5KiV"
A code that identifies a voucher. Pattern can use all letters of the English alphabet, Arabic numerals, and special characters.
"WVPblOYX"
A unique campaign name, identifies the voucher's parent campaign.
"Gift Card Campaign"
Assigned by the Voucherify API, identifies the voucher's parent campaign.
"camp_FNYR4jhqZBM9xTptxDGgeNBV"
Tag defining the category that this voucher belongs to. Useful when listing vouchers using the List Vouchers endpoint.
Unique category ID assigned by Voucherify.
"cat_0bb343dee3cdb5ec0c"
Defines the type of the voucher.
GIFT_VOUCHER, DISCOUNT_VOUCHER, LOYALTY_CARD Contains information about discount.
Show child attributes
Defines the type of the voucher.
AMOUNT Amount taken off the subtotal of a price. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $10 discount is written as 1000.
Formula used to dynamically calculate the discount.
Maximum discount amount per order.
Defines how the discount is applied to the customer's order.
APPLY_TO_ORDER, APPLY_TO_ITEMS, APPLY_TO_ITEMS_PROPORTIONALLY, APPLY_TO_ITEMS_PROPORTIONALLY_BY_QUANTITY, APPLY_TO_ITEMS_BY_QUANTITY Flag indicating whether the discount was calculated using a formula.
Object representing gift parameters. Child attributes are present only if type is GIFT_VOUCHER. Defaults to null.
Show child attributes
Total gift card income over the lifetime of the card. The value is multiplied by 100 to represent 2 decimal places. For example 10000 cents for $100.00.
10000
Total amount of subtracted credits over the gift card lifetime. The value is multiplied by 100 to represent 2 decimal places. For example 10000 cents for $100.00.
Available funds. The value is multiplied by 100 to represent 2 decimal places. For example 10000 cents for $100.00.
500
Defines how the credits are applied to the customer's order.
APPLY_TO_ORDER, APPLY_TO_ITEMS Object representing loyalty card parameters. Child attributes are present only if type is LOYALTY_CARD. Defaults to null.
Show child attributes
Total number of points added to the loyalty card over its lifespan.
7000
Points available for reward redemption. This is calculated as follows: balance = points - expired_points - subtracted_points - redemption.redeemed_points.
6970
The next closest date when the next set of points are due to expire.
"2023-05-30"
The amount of points that are set to expire next.
Shows the number of pending points that will be added to the loyalty card when they are activated automatically or manually.
Shows the total number of expired points over the lifetime of the loyalty card.
Shows the total number of subtracted points over the lifetime of the loyalty card.
Activation timestamp defines when the code starts to be active in ISO 8601 format. Voucher is inactive before this date.
"2021-12-01T00:00:00.000Z"
Expiration timestamp defines when the code expires in ISO 8601 format. Voucher is inactive after this date.
"2021-12-31T00:00:00.000Z"
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.
Show child attributes
Defines the amount of time an earning rule will be active in ISO 8601 format. For example, an earning rule with a duration of PT1H will be valid for a duration of one hour.
"PT1H"
Defines the intervening time between two time points in ISO 8601 format, expressed as a duration. For example, an earning rule with an interval of P2D will be valid every other day.
"P2D"
Integer array corresponding to the particular days of the week in which the voucher is valid.
0 Sunday1 Monday2 Tuesday3 Wednesday4 Thursday5 Friday6 Saturday0, 1, 2, 3, 4, 5, 6 Determines the hours of validity, e.g. to create a happy hours scenario.
Show child attributes
Defines the recurring period(s) when the resource is active. The periods should not overlap.
Show child attributes
Defines the starting hour of validity in the HH:mm format. The resource is inactive before this time.
"12:00"
Integer array corresponding to the particular days of the week in which the resource is valid.
0 Sunday1 Monday2 Tuesday3 Wednesday4 Thursday5 Friday6 Saturday0, 1, 2, 3, 4, 5, 6 Defines the ending hour of validity in the HH:mm format. The resource is inactive after this time.
"14:00"
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 voucherfalse indicates an inactive voucherAn optional field to keep any extra textual information about the code such as a code description and details.
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.
Stores links to images of QR and barcode that correspond to an encrypted voucher code.
Show child attributes
Stores Quick Response (QR) representation of encrypted code.
Show child attributes
Encrypted voucher code ID.
"U2FsdGVkX19ucFhvVmBVpVYG5KoswTsjSIaqoKg5L9ie4BK+t4pp7U7oFzjGJzj9q/bmuMOj9mEFiVKDMIkSaruKedMvHbKoPX5Sg+BaZk5QwXMf8k/OzSlOEVybpwSq+AiqPoNtjeuqtIgkDyvT6Q=="
URL to QR code
Optional: Attach query parameters to base URL to customize the image of the encrypted voucher code.
size: integer value from 1 to 100format: string, either png (default) or svg"https://dev.dl.voucherify.io/api/v1/assets/qr/U2FsdGVkX19ucFhvVmBVpVYG5KoswTsjSIaqoKg5L9ie4BK%2Bt4pp7U7oFzjGJzj9q%2FbmuMOj9mEFiVKDMIkSaruKedMvHbKoPX5Sg%2BBaZk5QwXMf8k%2FOzSlOEVybpwSq%2BAiqPoNtjeuqtIgkDyvT6Q%3D%3D"
Stores barcode representation of encrypted code.
Show child attributes
Encrypted voucher code ID.
"U2FsdGVkX19eJhGfWwUrH9+tulBkON+AnMktic+N6CVWzZ9+fHVxuVx22WakrzxiWXy0skuvvEHSeZIw9HlgyIJ+kJ1iPdUKpyENuNYJKzoZlO0mmTf6WQM6/pFs61apEn9SJx32ttCF6d3oxKISQQ=="
URL to barcode
Optional: Attach query parameters to base URL to customize the image of the encrypted voucher code.
size: integer value from 1 to 100format: string, either png (default) or svg"https://dev.dl.voucherify.io/api/v1/assets/barcode/U2FsdGVkX19eJhGfWwUrH9%2BtulBkON%2BAnMktic%2BN6CVWzZ9%2BfHVxuVx22WakrzxiWXy0skuvvEHSeZIw9HlgyIJ%2BkJ1iPdUKpyENuNYJKzoZlO0mmTf6WQM6%2FpFs61apEn9SJx32ttCF6d3oxKISQQ%3D%3D"
Flag indicating whether this voucher is a referral code; true for campaign type REFERRAL_PROGRAM.
Timestamp representing the date and time when the voucher was created. The value is shown in the ISO 8601 format.
"2021-12-22T10:13:06.487Z"
Timestamp representing the date and time when the voucher was last updated in ISO 8601 format.
"2021-12-22T10:14:45.316Z"
Unique customer identifier of the redeemable holder. It equals to the customer ID assigned by Voucherify.
"cust_eWgXlBBiY6THFRJwX45Iakv4"
Unique identifier of the referring person.
"cust_Vzck5i8U3OhcEUFY6MKhN9Rv"
The type of the object represented by JSON. Default is voucher.
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.
Show child attributes
The type of the object represented is by default list. To get this list, you need to make a call to the endpoint returned in the url attribute.
Publication events counter.
0
The endpoint where this list of publications can be accessed using a GET method. /v1/vouchers/{voucher_code}/publications
"/v1/vouchers/WVPblOYX/publications?page=1&limit=10"
Stores a summary of redemptions that have been applied to the voucher.
Show child attributes
How many times a voucher can be redeemed. A null value means unlimited.
How many times a voucher has already been redeemed.
1
Total loyalty points redeemed.
100000
The type of the object represented is by default list. To get this list, you need to make a call to the endpoint returned in the url attribute.
The endpoint where this list of redemptions can be accessed using a GET method. /v1/vouchers/{voucher_code}/redemptions
"/v1/vouchers/WVPblOYX/redemptions?page=1&limit=10"
Contains details about the category.
Show child attributes
Unique category ID assigned by Voucherify.
Category name.
Category hierarchy. Categories with lower hierarchy are processed before categories with higher hierarchy value.
x >= 0The type of the object represented by the JSON. This object stores information about the category.
category Timestamp representing the date and time when the category was created. The value is shown in the ISO 8601 format.
"2022-07-14T10:45:13.156Z"
Timestamp representing the date and time when the category was updated. The value is shown in the ISO 8601 format.
"2022-08-16T10:52:08.094Z"
List of Validation Rules Assignments
Show child attributes
The type of the object represented by JSON. This object stores information about validation rules assignments.
list Identifies the name of the attribute that contains the array of validation rules assignments.
data Contains array of validation rules assignments.
Show child attributes
The unique identifier for a assignment
The unique identifier for a rule
The unique identifier for a related object
The type of related object
The type of the object represented by JSON.
validation_rules_assignment Timestamp representing the date and time when the object was created. The value is shown in the ISO 8601 format.
"2022-03-09T11:19:04.819Z"
Timestamp representing the date and time when the object was last updated in ISO 8601 format.
"2022-03-09T11:19:04.819Z"
The validation status of the assignment
VALID, PARTIALLY_VALID, INVALID The list of omitted rules
Total number of validation rules assignments.
x >= 0Customer's source_id.
Was this page helpful?