### Install Ruby SDK
Source: https://docs.voucherify.io/docs/sdks
Install the Ruby SDK using the gem command.
```Shell
gem install voucherify
```
--------------------------------
### Install Python SDK
Source: https://docs.voucherify.io/docs/sdks
Install the Python SDK using pip.
```Shell
pip install voucherify
```
--------------------------------
### Import Vouchers to Campaign - Example
Source: https://docs.voucherify.io/api-reference/campaigns/import-vouchers-to-campaign
Imports vouchers to an existing campaign. This request starts a bulk process. The result returns an async ID to verify the status.
```yaml
openapi: 3.0.1
info:
title: Voucherify API - Campaigns
version: v2018-08-01
description: >-
Voucherify promotion engine REST API. Please see
https://docs.voucherify.io/docs for more details.
contact:
name: Voucherify Team
url: https://www.voucherify.io/contact-support
email: support@voucherify.io
termsOfService: https://www.voucherify.io/legal/subscription-agreement
license:
name: MIT
url: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/LICENSE
servers:
- url: https://{cluster}.voucherify.io
description: Base URL
variables:
cluster:
default: api
enum:
- api
- us1.api
- as1.api
- download
- us1.download
- as1.download
security: []
paths:
/v1/campaigns/{campaignId}/import:
parameters:
- schema:
$ref: '#/components/schemas/ParameterCampaignId'
name: campaignId
in: path
required: true
description: >-
The ID of an existing campaign to which you're importing the codes.
You can either pass the campaign ID, which was assigned by Voucherify,
or the name of the campaign as the path parameter value.
post:
tags:
- Campaigns
summary: Import Vouchers to Campaign
description: >-
Imports vouchers to an **existing** campaign.
This API request starts a process that affects Voucherify data in bulk.
In case of small jobs (like bulk update) the request is put into a queue
and processed once every other bulk request placed in the queue prior to
this request is finished. However, when the job takes a longer time
(like vouchers generation) then it is processed in small portions in a
round-robin fashion. When there is a list of vouchers generation
scheduled, then they will all have the `IN_PROGRESS` status shortly.
This way, small jobs added just after scheduling big jobs of the same
type will be processed in a short time window.
The result will return the async ID. You can verify the status of your
request via this [API
request](/api-reference/async-actions/get-async-action).
operationId: import-vouchers-to-campaign
parameters: []
requestBody:
description: >-
Discount type, expiration date and the remaining attributes will be
taken from the [Campaign](/api-reference/campaigns/get-campaign)
settings.
content:
application/json:
schema:
$ref: '#/components/schemas/CampaignsImportCreateRequestBody'
examples:
Example:
value:
- code: CODE7
category: First
redemption:
quantity: 1
metadata:
season: Fall
additional_info: secret-code1
active: true
- code: CODE8
category: Second
redemption:
quantity: 18
metadata:
season: Fall
additional_info: secret-code1
active: true
- code: CODE9
redemption:
quantity: 4
metadata:
season: Fall
additional_info: secret-code1
active: true
Gift Cards:
value:
- code: CODE13
category: First
redemption:
quantity: 1
metadata:
season: Fall
additional_info: secret-code1
gift:
amount: 500
active: true
- code: CODE14
category: Second
redemption:
quantity: 18
metadata:
season: Fall
additional_info: secret-code1
gift:
amount: 2000
active: true
- code: CODE15
redemption:
quantity: 4
metadata:
season: Fall
additional_info: secret-code1
active: false
Loyalty Cards:
value:
- code: CODE10
category: First
redemption:
quantity: 1
metadata:
season: Fall
additional_info: secret-code1
loyalty_card:
points: 300
```
--------------------------------
### Install .NET SDK
Source: https://docs.voucherify.io/docs/sdks
Install the .NET SDK for client-side or server-side applications using NuGet.
```Shell
Install-Package Voucherify.Client
```
```Shell
Install-Package Voucherify
```
--------------------------------
### Install JavaScript SDK
Source: https://docs.voucherify.io/docs/sdks
Use npm to install the latest JavaScript and Node.js SDK.
```Shell
npm install @voucherify/sdk
```
--------------------------------
### Order Creation Example
Source: https://docs.voucherify.io/guides/checking-eligibility
An example demonstrating the structure of an order object, including items, metadata, and stacking rules.
```APIDOC
## POST /v1/orders
### Description
Creates a new order with specified items, customer details, and optional metadata.
### Method
POST
### Endpoint
/v1/orders
### Parameters
#### Request Body
- **customer_id** (string) - Optional - The ID of the customer associated with the order.
- **items** (array) - Required - A list of items included in the order.
- **source_id** (string) - Required - The unique identifier for the item.
- **related_object** (string) - Required - The type of object the item relates to (e.g., "product").
- **quantity** (integer) - Required - The number of units for this item.
- **price** (integer) - Required - The price of the item in the smallest currency unit (e.g., cents).
- **product** (object) - Optional - Details about the product.
- **name** (string) - Required - The name of the product.
- **metadata** (object) - Optional - Custom key-value pairs to store additional information.
- **referrer_id** (string) - Optional - The ID of the referrer, if applicable.
- **stacking_rules** (object) - Optional - Rules governing how vouchers can be stacked with this order.
- **redeemables_limit** (integer) - Optional - The maximum number of redeemables that can be applied to this order.
- **applicable_redeemables_limit** (integer) - Optional - The maximum number of applicable redeemables that can be applied to this order.
### Request Example
```json
{
"customer_id": null,
"items": [
{
"source_id": "digital_book",
"related_object": "product",
"quantity": 1,
"price": 1500,
"product": {
"name": "Digital Book"
}
}
],
"metadata": {},
"referrer_id": null,
"stacking_rules": {
"redeemables_limit": 30,
"applicable_redeemables_limit": 5
}
}
```
### Response
#### Success Response (200)
- **object** (string) - The type of object returned (e.g., "order").
- **id** (string) - The unique identifier for the created order.
- **customer_id** (string) - The ID of the customer associated with the order.
- **items** (array) - A list of items included in the order.
- **metadata** (object) - Custom key-value pairs associated with the order.
- **referrer_id** (string) - The ID of the referrer, if applicable.
- **stacking_rules** (object) - Rules governing how vouchers can be stacked with this order.
#### Response Example
```json
{
"object": "order",
"id": "ord_abc123xyz",
"customer_id": null,
"items": [
{
"source_id": "digital_book",
"related_object": "product",
"quantity": 1,
"price": 1500,
"product": {
"name": "Digital Book"
}
}
],
"metadata": {},
"referrer_id": null,
"stacking_rules": {
"redeemables_limit": 30,
"applicable_redeemables_limit": 5
}
}
```
```
--------------------------------
### Install Deprecated Node.js SDK
Source: https://docs.voucherify.io/docs/sdks
Installation command for the deprecated Node.js SDK version.
```Shell
npm install voucherify
```
--------------------------------
### Add Member Response Example
Source: https://docs.voucherify.io/api-reference/loyalties/add-member
Example of the loyalty card object returned upon successfully adding a member to a loyalty program.
```json
id: v_0TxKw1bm0oZuS5lwA8526vze1OBMV1OH
code: KpzbHUY5
campaign: Loyalty Campaign
campaign_id: camp_eTIsUtuzkRXQT6rsUQqrS5Gw
category: New Customers
category_id: cat_0b6152ce12414820dc
categories:
- id: cat_0b6152ce12414820dc
name: New Customers
hierarchy: 0
created_at: '2022-07-14T20:17:07.657Z'
object: category
```
--------------------------------
### Create Order Request Examples
Source: https://docs.voucherify.io/api-reference/orders/create-order
Examples of JSON request bodies for the Create Order endpoint, demonstrating both simple and complex order structures including customer and item details.
```yaml
amount: 20000
customer:
source_id: sample_customer
status: PAID
items:
- quantity: 1
price: 20000
source_id: sample product1
related_object: product
product:
metadata:
key: value
```
```yaml
source_id: new
status: FULFILLED
metadata:
location_id:
- L1
- L2
payment_mean:
- paypal
- credit-card
customer:
source_id: bob.smith.1@email.com
name: Bob Smith
description: A nice customer
email: bob.smith.1@email.com
phone: +1 933 222 3333
address:
city: New York
country: United Statese
line_1: 123 Main St
line_2: APT 3 BLG 4
postal_code: '10001'
state: NY
metadata:
lang: en
test: false
birthdate: '2022-01-02'
referrer:
source_id: jane.smith@email.com
name: Jane Smith
description: A really nice customer
email: jane.smith@email.com
phone: +1 933 222 3334
address:
city: New York
country: United States
line_1: 123 Main St.
line_2: APT 3 BLG 4
postal_code: '10001'
state: NY
metadata:
lang: en
test: false
birthday: '2022-03-03'
items:
- source_id: prod_1
related_object: product
quantity: 2
product:
name: Apple iPhone 12
price: 60000
metadata:
color:
- purple
vendor: mall
override: true
- source_id: ComicBook_1
related_object: sku
quantity: 1
product:
source_id: Books
name: Comic Books1
price: 2100
metadata:
color:
- silver
vendor: Bookstore1
override: true
sku:
sku: Comics1
source_id: ComicBook_1
price: 1700
metadata:
color:
- golden
vendor: islands
override: true
```
--------------------------------
### Redeem Voucher Example
Source: https://docs.voucherify.io/api-reference/redemptions/redeem-voucher
This example demonstrates a successful voucher redemption, showing the structure of the response including order details, customer information, and voucher specifics.
```APIDOC
## POST /vouchers/{voucher_id}/redemption
### Description
Redeems a voucher for a customer. This endpoint is typically used internally or via SDKs to process voucher redemptions.
### Method
POST
### Endpoint
/vouchers/{voucher_id}/redemption
### Parameters
#### Path Parameters
- **voucher_id** (string) - Required - The unique identifier of the voucher to be redeemed.
#### Request Body
(The request body is not explicitly defined in the provided text, but typically includes customer identification and potentially order details.)
### Request Example
```json
{
"customer_id": "cust_eWgXlBBiY6THFRJwX45Iakv4",
"order": {
"id": "ord_S4BvUj64TlGqVZDOeud7z3rU",
"amount": 6000,
"items": [
{
"product_id": "prod_0a9f9ab4ab019a42d5",
"quantity": 1,
"amount": 3300
},
{
"product_id": "prod_0a9f9aeddb019a42db",
"quantity": 2,
"amount": 3400
}
]
},
"tracking_id": "track_9B0kB92+bJa8a+PegaWREw=="
}
```
### Response
#### Success Response (200 OK)
- **id** (string) - The unique identifier of the redemption.
- **object** (string) - The type of object, typically "redemption".
- **date** (string) - The date and time the voucher was redeemed.
- **customer_id** (string) - The ID of the customer who redeemed the voucher.
- **tracking_id** (string) - The tracking ID associated with the redemption.
- **metadata** (object) - Custom data associated with the redemption.
- **amount** (integer) - The amount redeemed.
- **result** (string) - The result of the redemption (e.g., "SUCCESS").
- **order** (object) - Details of the order associated with the redemption.
- **customer** (object) - Details of the customer who redeemed the voucher.
- **related_object_type** (string) - The type of the related object (e.g., "voucher").
- **related_object_id** (string) - The ID of the related object.
- **voucher** (object) - Details of the voucher that was redeemed.
#### Response Example
```json
{
"id": "r_0c5e8a38730ccec0d5",
"object": "redemption",
"date": "2023-01-27T12:34:57.100Z",
"customer_id": "cust_eWgXlBBiY6THFRJwX45Iakv4",
"tracking_id": "track_9B0kB92+bJa8a+PegaWREw==",
"metadata": null,
"amount": 2000,
"result": "SUCCESS",
"order": {
"id": "ord_S4BvUj64TlGqVZDOeud7z3rU",
"source_id": null,
"created_at": "2023-01-27T12:34:57.086Z",
"updated_at": null,
"status": "PAID",
"amount": 6000,
"discount_amount": 2000,
"total_discount_amount": 2000,
"total_amount": 4000,
"applied_discount_amount": 2000,
"total_applied_discount_amount": 2000,
"items": [
{
"object": "order_item",
"product_id": "prod_0a9f9ab4ab019a42d5",
"quantity": 1,
"amount": 3300,
"price": 3000,
"subtotal_amount": 3300
},
{
"object": "order_item",
"product_id": "prod_0a9f9aeddb019a42db",
"quantity": 2,
"amount": 3400,
"price": 3000,
"subtotal_amount": 3400
}
],
"metadata": {},
"customer": {
"id": "cust_eWgXlBBiY6THFRJwX45Iakv4",
"object": "customer"
},
"customer_id": "cust_eWgXlBBiY6THFRJwX45Iakv4",
"referrer_id": null,
"object": "order",
"redemptions": {
"r_0c5e8a38730ccec0d5": {
"date": "2023-01-27T12:34:57.100Z",
"related_object_type": "voucher",
"related_object_id": "v_UFAc7FTVO0HtJV2hWZls4O7eqHMyn62g",
"related_object_parent_id": "camp_B2Gx83JsSbmvj05MOwxYbNm6"
}
}
},
"customer": {
"id": "cust_eWgXlBBiY6THFRJwX45Iakv4",
"name": "Bob Jones",
"email": "bob.jones@email.com",
"source_id": "36_bob",
"metadata": {
"age": 26,
"favorite_brands": [
"Nike",
"Adidas",
"Reebok"
],
"accepts_marketing": false,
"acquisition_channel": "Facebook"
},
"object": "customer"
},
"related_object_type": "voucher",
"related_object_id": "v_UFAc7FTVO0HtJV2hWZls4O7eqHMyn62g",
"voucher": {
"id": "v_UFAc7FTVO0HtJV2hWZls4O7eqHMyn62g",
"code": "CODE14",
"campaign": "Gift Card Campaign",
"campaign_id": "camp_B2Gx83JsSbmvj05MOwxYbNm6",
"category": "Second",
"category_id": "cat_0bb343dee3cdb5ec0c",
"categories": [],
"type": "GIFT_VOUCHER",
"discount": null,
"gift": {
"amount": 2000,
"balance": 0,
"effect": null
},
"loyalty_card": null,
"start_date": "2020-08-16T00:00:00.000Z",
"expiration_date": null,
"validity_timeframe": null,
"validity_day_of_week": null,
"active": true,
"additional_info": "secret-code1",
"metadata": {
"region": "APAC",
"season": "Fall"
},
"assets": {
"qr": {
"id": "U2FsdGVkX1+VibJ6VGxrSVw5qmdbPMP3aP8HfcngMxtQc9Bm649CK1dK36e8YR820Ct26IkvDemEDzV8ozhB3F2BpazbgvCmhAo2Gvmo2WtwBwPh2ISAPJiXQCHRjwmKiqogjqQaNKWLxwDIBUc2jQ==",
"url": "{{internalVoucherifyURL}}"
},
"barcode": {
"id": "U2FsdGVkX1/GVIi0p5fL5hxAY/ZBmuAU7nYYS03umjd30dwI5v5ZbpNc3Q5MiYbMuIOIT0H2fUTTwd//S4R9AB+60T/x4kSKu3lgfa9KgJmbyrzXm7Ggly06/qph4/asJaZVZIXEba4WJCeHqXCEgg==",
"url": "{{internalVoucherifyURL}}"
}
},
"is_referral_code": false,
"created_at": "2022-09-23T11:05:42.164Z",
"updated_at": "2023-01-27T12:34:57.102Z",
"validation_rules_assignments": {
"object": "list",
"data_ref": "data",
"data": [],
"total": 0
}
}
}
```
```
--------------------------------
### Add Member Request Body Examples
Source: https://docs.voucherify.io/api-reference/loyalties/add-member
Examples of JSON payloads for assigning a loyalty card to a customer using different customer identification methods.
```json
customer: source_customer_1
metadata:
year: 2022
channel: postman
voucher: KpzbHUY5
```
```json
customer: cust_8KQmHxAERpgebYcFhSpZRr37
metadata:
year: 2022
channel: postman
voucher: KpzbHUY5
```
```json
customer:
source_id: source_customer_1
metadata:
year: 2022
channel: postman
voucher: KpzbHUY5
```
```json
customer:
id: cust_8KQmHxAERpgebYcFhSpZRr37
metadata:
year: 2022
channel: postman
voucher: KpzbHUY5
```
--------------------------------
### Async Action Response Example
Source: https://docs.voucherify.io/api-reference/async-actions/get-async-action
This is an example of a successful response when retrieving an async action. It includes the action's ID, type, status, detailed results (like imported/failed counts and reasons for failure), and timestamps.
```json
{ "id": "aa_0af9b22296cf473a10", "type": "CAMPAIGN.VOUCHERS_IMPORT", "status": "DONE", "result": { "message": "0 voucher(s) imported successfully, 3 failed.", "failed": [ { "code": "CODE9", "reason": "unit: must be a number, property is required (actual value is 'EUR')" }, { "code": "CODE8", "reason": "unit: must be a number, property is required (actual value is 'EUR')" }, { "code": "CODE7", "reason": "unit: must be a number, property is required (actual value is 'EUR')" } ], "done_count": 0, "failed_count": 3 }, "created_at": "2023-01-20T07:23:43.289Z", "updated_at": "2023-01-20T07:23:44.044Z", "request_id": "v-0c553fdb325688d510", "progress": 100, "processing_time": 755, "object": "async_action" }
```
--------------------------------
### OAuth Error Response Example (Missing Parameters)
Source: https://docs.voucherify.io/api-reference/oauth/introspect-oauth-20-token
This example demonstrates an error response when required parameters are missing in the request body.
```json
{
"code": 400,
"key": "missing_parameters",
"message": "Missing parameters"
}
```
--------------------------------
### Voucher Redemption Examples
Source: https://docs.voucherify.io/api-reference/validations/validate-voucher
Examples demonstrating voucher redemption scenarios, including gift cards and referral codes, along with error handling.
```APIDOC
## Voucher Redemption Scenarios
### Gift Card Redemption
This section details the structure of a successful gift card redemption, including order details and remaining balance.
### Referral Code Redemption
This section details the structure of a successful referral code redemption, including order details and discount applied.
### Error Handling for Redemptions
This section outlines common error responses when redeeming vouchers, such as missing parameters or validation failures.
#### 400 Bad Request
Returns an error if request body is missing parameters or fails validation.
##### Example: Missing Reward
```json
{
"code": 400,
"key": "missing_reward",
"message": "Missing reward",
"details": "A reward is required when redeeming a LOYALTY_CARD",
"request_id": "v-0bcb925c6d90f7f8fc",
"error": {
"message": "Missing reward = please add one."
}
}
```
##### Example: Missing Applicable Order Items
```json
{
"code": 400,
"key": "missing_order_items_amount",
"message": "Missing applicable order items",
"details": "At least one applicable order item with amount is required to redeem this GIFT_VOUCHER",
"request_id": "v-0bcccfd04085cf2540",
"error": {
"message": "Request should contain an amount for the item."
}
}
```
##### Example: Metadata Validation Failed
```json
{
"code": 400,
"key": "metadata_validation_failed",
"message": "Metadata validation failed",
"details": "location_id: must be an array, and every element: must be a string, must be equal to one of L1,L2,L3 (actual value is 'L1')",
"request_id": "v-0bcced27715305d3fa",
"error": {
"message": "Metadata validation failed."
}
}
```
```
--------------------------------
### Example Reward Assignment Response
Source: https://docs.voucherify.io/api-reference/loyalties/get-campaign-reward-assignment
This is an example of a successful response when retrieving a specific reward assignment. It includes details about the assignment, the associated reward, and the campaign.
```json
{
"id": "rewa_1gJ6VyYQI0IcnEvhArbr9XFH",
"reward_id": "rew_injbwG52POgfpSogTlQl4hA6",
"related_object_id": "camp_Vr97XXNOnFEUIMFymKK99FAA",
"related_object_type": "campaign",
"parameters": {
"loyalty": {
"points": 10
}
},
"created_at": "2022-06-13T11:56:49.185Z",
"updated_at": null,
"object": "reward_assignment"
}
```
--------------------------------
### Example of a Resource In Use Error Response
Source: https://docs.voucherify.io/api-reference/rewards/delete-reward
This example shows the JSON response when attempting to delete a reward that is currently in use by other resources. It details the error code, key, message, and provides specific information about the related resources.
```json
{
"code": 400,
"key": "resource_in_use",
"message": "Resource in use",
"details": "Resource reward with id rew_fcYALROsORec6cP0VBItCVfq is in use by reward_assignments with ids [rewa_5WV7H3y2lT3GGl03Xjw29IEc]",
"request_id": "v-0b8c7b967950216291",
"related_object_ids": [
"rewa_5WV7H3y2lT3GGl03Xjw29IEc"
],
"related_object_type": "reward_assignment"
}
```
--------------------------------
### Location Response Example
Source: https://docs.voucherify.io/api-reference/locations/get-location
Example JSON response body returned by the GET location endpoint.
```json
{
"id": "loc_NoMGXmHO9OUs7iz9mGWpamma",
"object": "location",
"name": "Belleville",
"shape": {
"type": "circle",
"format": "distance",
"distance": {
"center": "geo:40.79372699823857,-74.15092132694554",
"radius": "1.54 km"
}
},
"created_at": "2022-07-15T06:04:36.924Z",
"updated_at": null
}
```
--------------------------------
### Create Publication GET Request
Source: https://docs.voucherify.io/api-reference/publications/create-publication-with-get
Example of a GET request to create a publication by specifying a campaign name and customer source ID.
```markdown
/publications/create?campaign[name]=BlackFriday&customer[source_id]=Customer_Source_ID
```
--------------------------------
### GET /orders
Source: https://docs.voucherify.io/api-reference/orders/list-orders
Retrieves a list of orders. The provided content shows examples of order objects, including their items, customer details, and redemption information.
```APIDOC
## GET /orders
### Description
Retrieves a list of orders. This endpoint is useful for fetching order history, details, and associated customer and redemption data.
### Method
GET
### Endpoint
/orders
### Parameters
#### Query Parameters
- **limit** (integer) - Optional - The maximum number of orders to return.
- **page** (integer) - Optional - The page number for pagination.
### Response
#### Success Response (200)
- **orders** (array) - A list of order objects.
- **id** (string) - The unique identifier for the order.
- **status** (string) - The current status of the order (e.g., PAID).
- **amount** (integer) - The total amount of the order before discounts.
- **discount_amount** (integer) - The total discount amount applied to the order.
- **total_amount** (integer) - The final amount after discounts.
- **items** (array) - A list of items included in the order.
- **product_id** (string) - The ID of the product.
- **quantity** (integer) - The quantity of the product.
- **amount** (integer) - The amount for this item.
- **product** (object) - Details about the product.
- **name** (string) - The name of the product.
- **price** (integer) - The price of the product.
- **customer** (object) - Details about the customer who placed the order.
- **id** (string) - The unique identifier for the customer.
- **redemptions** (object) - Information about redemptions associated with the order.
- **date** (string) - The date and time of the redemption.
- **related_object_type** (string) - The type of object redeemed (e.g., voucher, promotion_tier).
- **related_object_id** (string) - The ID of the redeemed object.
### Response Example
```json
{
"orders": [
{
"id": "ord_N3YBowDTZs0UH2hHoMZLbUDN",
"status": "PAID",
"amount": 71600,
"discount_amount": 7160,
"total_amount": 64440,
"items": [
{
"product_id": "prod_0b7d7c4e814be5c502",
"quantity": 1,
"amount": 70000,
"product": {
"name": "Apple iPhone 12",
"price": 70000
}
}
],
"customer": {
"id": "cust_Vzck5i8U3OhcEUFY6MKhN9Rv"
},
"redemptions": {
"r_0ba9f57c37128ed639": {
"date": "2022-09-09T06:18:31.516Z",
"related_object_type": "promotion_tier",
"related_object_id": "promo_CQonGnrsFAdEJfJQ3oKB3a8G"
}
}
}
]
}
```
```
--------------------------------
### Install Java SDK
Source: https://docs.voucherify.io/docs/sdks
Configure the Java SDK using Maven or Gradle dependency management.
```XML
io.voucherify.client
voucherify-java-sdk
17.0.2
compile
```
```Groovy
repositories {
mavenCentral()
}
dependencies {
implementation "io.voucherify.client:voucherify-java-sdk:17.0.2"
}
```
--------------------------------
### List Promotion Stacks in Campaign
Source: https://docs.voucherify.io/api-reference/promotions/list-promotion-stacks-in-campaign
This OpenAPI definition describes the GET request to list promotion stacks for a specific campaign. It includes example response data.
```yaml
openapi: 3.0.1
info:
title: Voucherify API - Promotions
version: v2018-08-01
description: >-
Voucherify promotion engine REST API. Please see
https://docs.voucherify.io/docs for more details.
contact:
name: Voucherify Team
url: https://www.voucherify.io/contact-support
email: support@voucherify.io
termsOfService: https://www.voucherify.io/legal/subscription-agreement
license:
name: MIT
url: https://github.com/voucherifyio/voucherify-js-sdk/blob/main/LICENSE
servers:
- url: https://{cluster}.voucherify.io
description: Base URL
variables:
cluster:
default: api
enum:
- api
- us1.api
- as1.api
- download
- us1.download
- as1.download
security: []
paths:
/v1/promotions/{campaignId}/stacks:
parameters:
- schema:
$ref: '#/components/schemas/ParameterCampaignId'
name: campaignId
in: path
required: true
description: Unique campaign ID.
get:
tags:
- Promotions
summary: List Promotion Stacks in Campaign
description: >-
This method enables you to list promotion stacks from a specified
campaign.
operationId: list-promotion-stacks-in-campaign
parameters: []
responses:
'200':
description: Returns a list of promotion stack objects.
content:
application/json:
schema:
$ref: '#/components/schemas/PromotionsStacksListResponseBody'
examples:
Example:
value:
object: list
data_ref: data
data:
- id: stack_p0WhtyyDU95crobleMpRabhH
name: First stack
created_at: '2022-09-22T13:03:25.740Z'
campaign_id: camp_99HUWI53bVyLzPN1Fg5TBLWX
object: promotion_stack
tiers:
ids:
- promo_dJNhAEeV5sR5oPQq1UrUdnMC
- promo_aaAF8mVAzA0PF1igia2OC63d
hierarchy_mode: MANUAL
- id: stack_XAzn8AFR3Ks3DBPLAQxV7zHe
name: Second stack
created_at: '2022-09-22T13:03:25.903Z'
campaign_id: camp_99HUWI53bVyLzPN1Fg5TBLWX
object: promotion_stack
tiers:
ids:
- promo_aaAF8mVAzA0PF1igia2OC63d
- promo_dJNhAEeV5sR5oPQq1UrUdnMC
hierarchy_mode: MANUAL
total: 2
security:
- X-App-Id: []
X-App-Token: []
- X-Voucherify-OAuth:
- api
- promotions
components:
schemas:
ParameterCampaignId:
type: string
example: camp_rRsfatlwN7unSeUIJDCYedal
PromotionsStacksListResponseBody:
title: Promotions Stacks List Response Body
description: >-
Response body schema for **GET** `v1/promotions/stacks` and for **GET**
`v1/promotions/{campaignId}/stacks`.
type: object
properties:
object:
type: string
default: list
enum:
- list
description: >-
The type of the object represented by JSON. This object stores
information about promotion stacks in a dictionary.
data_ref:
type: string
default: data
enum:
- data
description: >-
Identifies the name of the attribute that contains the array of
promotion stack objects.
data:
type: array
description: Contains array of promotion stack objects.
items:
$ref: '#/components/schemas/PromotionStack'
total:
type: integer
minimum: 0
description: Total number of promotion stacks.
required:
- object
- data_ref
- data
- total
PromotionStack:
allOf:
- $ref: '#/components/schemas/PromotionStackBase'
- type: object
properties:
id:
type: string
description: Unique promotion stack ID.
created_at:
type: string
format: date-time
description: >-
Timestamp representing the date and time when the promotion
stack was created. The value is shown in the ISO 8601 format.
updated_at:
type: string
format: date-time
description: >-
Timestamp representing the date and time when the promotion
```
--------------------------------
### Validate Voucher Request Examples
Source: https://docs.voucherify.io/api-reference/validations/validate-voucher
Examples of request bodies for validating a voucher. The 'Free Shipping' example shows validation with customer and order details including multiple product variants. The 'Multiple Product Variants' example demonstrates validation using a customer source ID and order details.
```json
{
"customer": {
"id": "cust_4vMj8Twr5nBzvTrNCgipMb6M"
},
"order": {
"items": [
{
"product_id": "prod_0ba621bae5d39762ce",
"quantity": "1"
},
{
"product_id": "prod_0b661d404787ec6d3b",
"quantity": "1",
"price": 3100
}
]
}
}
```
```json
{
"customer": {
"source_id": "08dd9b5a-26de-44aa-a1d4-d9adfa9e8ec2"
},
"order": {
"items": [
{
"product_id": "prod_0ba621bae5d39762ce",
"quantity": "1"
},
{
"product_id": "prod_0b661d404787ec6d3b",
"quantity": "1",
"price": 3100
}
]
}
}
```
--------------------------------
### Install PHP SDK
Source: https://docs.voucherify.io/docs/sdks
Add the Voucherify SDK as a required module in your composer.json file.
```php
"require": {
"rspective/voucherify": "dev-master"
}
```
--------------------------------
### Install Android SDK
Source: https://docs.voucherify.io/docs/sdks
Configure the Android SDK using Gradle or Maven. Requires at least Java 6 or Android 2.3.3.
```Groovy
dependencies {
compile 'pl.rspective.voucherify.android.client:voucherify-android-sdk:0.6.0'
}
```
```XML
pl.rspective.voucherify.android.client
voucherify-android-sdk
0.6.0
```
--------------------------------
### Configure Amplience Installation Parameters
Source: https://docs.voucherify.io/integrations/amplience
JSON structure for providing Voucherify integration credentials during the extension registration process.
```json
{
"APP_ID":"[your Amplience integration keys ID]",
"SECRET_KEY":"[your Amplience integration secret key]"
}
```
--------------------------------
### Voucher Start Date
Source: https://docs.voucherify.io/api-reference/campaigns/update-campaign
Specifies the start date for voucher validity in date-time format.
```APIDOC
## Voucher Start Date
### Description
Specifies the start date for voucher validity.
### Format
date-time
```
--------------------------------
### Order Item Discount Example
Source: https://docs.voucherify.io/api-reference/validations/validate-promotions
This snippet demonstrates how a discount is applied to an order item, including product details and pricing.
```APIDOC
## Order Item with Discount
### Description
This section details an order item that has received a discount, including the original price, discounted amount, and applied discount.
### Method
N/A (This is a data representation example)
### Endpoint
N/A (This is a data representation example)
### Request Body
```json
{
"object": "order_item",
"product_id": "prod_0a9f9ab4ab019a42d5",
"quantity": 1,
"amount": 2900,
"discount_amount": 2100,
"applied_discount_amount": 2100,
"price": 2900,
"subtotal_amount": 800,
"product": {
"id": "prod_0a9f9ab4ab019a42d5",
"name": "Red T-Shirt"
}
}
```
### Response
#### Success Response (200)
This data structure represents a successful application of a discount to an order item.
#### Response Example
```json
{
"object": "order_item",
"product_id": "prod_0a9f9ab4ab019a42d5",
"quantity": 1,
"amount": 2900,
"discount_amount": 2100,
"applied_discount_amount": 2100,
"price": 2900,
"subtotal_amount": 800,
"product": {
"id": "prod_0a9f9ab4ab019a42d5",
"name": "Red T-Shirt"
}
}
```
```
--------------------------------
### Campaign ID Parameter Example
Source: https://docs.voucherify.io/api-reference/loyalties/get-campaign-reward-assignment
Example of a campaign ID parameter used in API requests.
```json
camp_rRsfatlwN7unSeUIJDCYedal
```
--------------------------------
### List All Categories (cURL)
Source: https://docs.voucherify.io/api-reference/categories/list-categories
Use this cURL command to fetch a list of all categories. Ensure you replace `{cluster}` with your Voucherify cluster URL and `` with your actual API credentials.
```bash
curl --request GET \
--url https://{cluster}.voucherify.io/v1/categories \
--header 'X-App-Id: ' \
--header 'X-App-Token: '
```
--------------------------------
### List Promotion Tiers (cURL)
Source: https://docs.voucherify.io/api-reference/client-side/list-promotion-tiers-client-side
Use this cURL command to fetch a list of promotion tiers. Ensure you replace placeholders like and with your actual credentials and origin.
```bash
curl --request GET \
--url https://api.voucherify.io/client/v1/promotions/tiers \
--header 'X-Client-Application-Id: ' \
--header 'X-Client-Token: ' \
--header 'origin: '
```