Skip to main content
POST
/
v1
/
vouchers
/
import
Import Vouchers
curl --request POST \
  --url https://{cluster}.voucherify.io/v1/vouchers/import \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'X-App-Id: <api-key>' \
  --header 'X-App-Token: <api-key>' \
  --data '[
  {
    "code": "PROMO-CODE30OFF-NO-EFFECT",
    "category": "new customer acquisition",
    "type": "DISCOUNT_VOUCHER",
    "active": true,
    "discount": {
      "amount_off": 3000,
      "type": "AMOUNT"
    },
    "start_date": "2020-12-01T23:00:00Z",
    "expiration_date": "2023-12-19T23:00:00Z",
    "redemption": {
      "quantity": 1
    },
    "metadata": {
      "unit": "EUR"
    },
    "additional_info": "secret-code1"
  },
  {
    "code": "PROMO-CODE30-PERCENT-NO-EFFECT",
    "type": "DISCOUNT_VOUCHER",
    "active": false,
    "discount": {
      "percent_off": 30,
      "type": "PERCENT"
    },
    "start_date": "2020-12-10T23:00:00Z",
    "expiration_date": "2023-12-31T23:00:00Z",
    "redemption": {
      "quantity": 1
    },
    "metadata": {
      "unit": "EUR"
    },
    "additional_info": "secret-code2"
  },
  {
    "code": "GIFT-CARD-100",
    "type": "GIFT_VOUCHER",
    "active": true,
    "category": "new customer acquisition",
    "gift": {
      "amount": 10000
    },
    "start_date": "2020-12-10T23:00:00Z",
    "expiration_date": "2023-12-31T23:00:00Z",
    "redemption": {
      "quantity": 5
    },
    "metadata": {
      "unit": "EUR"
    },
    "additional_info": "secret-GIFT-code2"
  },
  {
    "code": "PROMO-CODE1-PERCENT-EFFECT-ORDER",
    "type": "DISCOUNT_VOUCHER",
    "active": false,
    "discount": {
      "percent_off": 30,
      "type": "PERCENT",
      "effect": "APPLY_TO_ORDER"
    },
    "start_date": "2020-12-10T23:00:00Z",
    "expiration_date": "2023-12-31T23:00:00Z",
    "redemption": {
      "quantity": 1
    },
    "metadata": {
      "unit": "EUR"
    },
    "additional_info": "secret-code2"
  },
  {
    "code": "PROMO-CODE2-PERCENT-EFFECT-ITEM",
    "type": "DISCOUNT_VOUCHER",
    "active": false,
    "discount": {
      "percent_off": 30,
      "type": "PERCENT",
      "effect": "APPLY_TO_ITEMS"
    },
    "start_date": "2020-12-10T23:00:00Z",
    "expiration_date": "2023-12-31T23:00:00Z",
    "redemption": {
      "quantity": 1
    },
    "metadata": {
      "unit": "EUR"
    },
    "additional_info": "secret-code2"
  },
  {
    "code": "PROMO-CODE1-PERCENT-NO-EFFECT-REDEEMED-QUANTITY-ATTRIBUTE-DOESNT-GET-PASSED",
    "type": "DISCOUNT_VOUCHER",
    "active": false,
    "discount": {
      "percent_off": 30,
      "type": "PERCENT"
    },
    "start_date": "2020-12-10T23:00:00Z",
    "expiration_date": "2023-12-31T23:00:00Z",
    "redemption": {
      "quantity": 1,
      "redeemed_quantity": 1
    },
    "metadata": {
      "unit": "EUR"
    },
    "additional_info": "secret-code2"
  },
  {
    "code": "PROMO-CODE1-AMOUNT-EFFECT-ITEMS-PROPORTIONALLY",
    "type": "DISCOUNT_VOUCHER",
    "active": false,
    "discount": {
      "amount_off": 30,
      "type": "AMOUNT",
      "effect": "APPLY_TO_ITEMS_PROPORTIONALLY"
    },
    "start_date": "2020-12-10T23:00:00Z",
    "expiration_date": "2023-12-31T23:00:00Z",
    "redemption": {
      "quantity": 1
    },
    "metadata": {
      "unit": "EUR"
    },
    "additional_info": "secret-code2"
  },
  {
    "code": "PROMO-CODE1-FIXED-EFFECT-ORDER",
    "type": "DISCOUNT_VOUCHER",
    "active": false,
    "discount": {
      "fixed_amount": 30,
      "type": "FIXED",
      "effect": "APPLY_TO_ORDER"
    },
    "start_date": "2020-12-10T23:00:00Z",
    "expiration_date": "2023-12-31T23:00:00Z",
    "redemption": {
      "quantity": 1
    },
    "metadata": {
      "unit": "EUR"
    },
    "additional_info": "secret-code2"
  },
  {
    "code": "PROMO-CODE1-UNIT-SINGLE-ITEM-EFFECT-MISSING",
    "type": "DISCOUNT_VOUCHER",
    "active": false,
    "discount": {
      "unit_off": 1,
      "unit_type": "prod_0a9f9aeddb019a42db",
      "type": "UNIT",
      "effect": "ADD_MISSING_ITEMS"
    },
    "start_date": "2020-12-10T23:00:00Z",
    "expiration_date": "2023-12-31T23:00:00Z",
    "redemption": {
      "quantity": 1
    },
    "metadata": {
      "unit": "EUR"
    },
    "additional_info": "secret-code2"
  },
  {
    "code": "PROMO-CODE2-UNIT-MULTIPLE-ITEMS",
    "type": "DISCOUNT_VOUCHER",
    "active": true,
    "discount": {
      "type": "UNIT",
      "effect": "ADD_MANY_ITEMS",
      "units": [
        {
          "unit_off": 1,
          "unit_type": "prod_0a9f9aeddb019a42db",
          "effect": "ADD_MISSING_ITEMS"
        },
        {
          "unit_off": 1,
          "unit_type": "prod_0a9f9aeddb019a42db",
          "effect": "ADD_NEW_ITEMS"
        }
      ]
    },
    "start_date": "2020-12-10T23:00:00Z",
    "expiration_date": "2023-12-31T23:00:00Z",
    "redemption": {
      "quantity": 1
    },
    "metadata": {
      "unit": "EUR"
    },
    "additional_info": "secret-code2"
  },
  {
    "code": "PROMO-CODE1-SHIPPING",
    "type": "DISCOUNT_VOUCHER",
    "active": false,
    "discount": {
      "type": "UNIT",
      "unit_off": 1,
      "unit_type": "prod_5h1pp1ng",
      "effect": "ADD_MISSING_ITEMS"
    },
    "start_date": "2020-12-10T23:00:00Z",
    "expiration_date": "2023-12-31T23:00:00Z",
    "redemption": {
      "quantity": 1
    },
    "metadata": {
      "unit": "EUR"
    },
    "additional_info": "secret-code2"
  }
]'
{
  "async_action_id": "aa_0aac93c6af84485df3"
}

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.

Body

application/json · Vouchers Import Request Body · array

The request body is an array of objects. Each object contains details about a specific voucher.

Request body schema for POST v1/vouchers/import.

  • Voucher Import Gift
  • Voucher Import Discount
code
string
required

Value representing the imported code.

gift
object
required

Contains current gift card balance information.

redemption
object

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

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
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.

category
string

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

start_date
string<date-time>

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

  • YYYY-MM-DD
  • YYYY-MM-DDTHH
  • YYYY-MM-DDTHH:mm
  • YYYY-MM-DDTHH:mm:ss
  • YYYY-MM-DDTHH:mm:ssZ
  • YYYY-MM-DDTHH:mm:ss.SSSZ
Example:

"2020-12-28T12:49:16.272Z"

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. Allowed date formats are:

  • YYYY-MM-DD
  • YYYY-MM-DDTHH
  • YYYY-MM-DDTHH:mm
  • YYYY-MM-DDTHH:mm:ss
  • YYYY-MM-DDTHH:mm:ssZ
  • YYYY-MM-DDTHH:mm:ss.SSSZ
Example:

"2053-12-28T12:49:16.272Z"

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
additional_info
string

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

type
enum<string>
default:GIFT_VOUCHER

Defines the type of the voucher.

Available options:
GIFT_VOUCHER

Response

202 - application/json

Returns ID of the scheduled async action. The response informs you that your request has been accepted and vouchers will be added to the repository asynchronously. To check the import status and result, copy the async_action_id from the response and pass it using the <!-- [Get Async Action](OpenAPI.json/paths/~1async-actions~1{asyncActionId}/get) -->Get Async Action endpoint.

Response body schema for POST v1/vouchers/import. Response to requests that are processed asynchronously.

async_action_id
string
required

The ID of the scheduled asynchronous action.

Example:

"aa_0a875d56c805df6601"

I