Skip to main content
POST
/
v1
/
campaigns
/
{campaignId}
/
import
curl --request POST \
--url https://{cluster}.voucherify.io/v1/campaigns/{campaignId}/import \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-App-Id: <api-key>' \
--header 'X-App-Token: <api-key>' \
--data '[
{
"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
}
]'
{
"async_action_id": "aa_0a875d56c805df6601"
}

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

Example:

"camp_rRsfatlwN7unSeUIJDCYedal"

Body

application/json · Campaigns Import Create Request Body · array

Discount type, expiration date and the remaining attributes will be taken from the <!-- [Campaign](OpenAPI.json/components/schemas/Campaign) -->Campaign settings.

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

  • Voucher Import Loyalty Card
  • Voucher Import Gift
  • Voucher Import Discount
code
string
required

Value representing the imported code.

loyalty_card
object
required

Simplified loyalty card data.

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:LOYALTY_CARD

Defines the type of the voucher.

Available options:
LOYALTY_CARD

Response

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

Response body schema for POST v1/campaigns/{campaignId}/import. Response to requests that are processed asynchronously.

async_action_id
string
required

The ID of the scheduled asynchronous action.

Example:

"aa_0a875d56c805df6601"

I