---
title: "Import Vouchers to Campaign"
method: POST
path: "/v1/campaigns/{campaignId}/import"
tags: ["Campaigns"]
---

# Import Vouchers to Campaign

`POST /v1/campaigns/{campaignId}/import`

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

## Request body

- CampaignsImportVoucherItem[] — Request body schema for **POST** `v1/campaigns/{campaignId}/import`.
  - union
    - VoucherImportLoyaltyCard — Object model for gift card object being imported.
      - `code` string, required — Value representing the imported code.
      - `redemption` object — Stores the quantity of redemptions that can be applied to the voucher.
        - `quantity` integer — How many times a voucher can be redeemed. A `null` value means unlimited.
      - `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](/api-reference/vouchers/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
      - `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
      - `validity_timeframe` ValidityTimeframe — 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`.
        - `duration` string — 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.
        - `interval` string — 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.
      - `validity_day_of_week` 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` 'LOYALTY_CARD' — Defines the type of the voucher.
      - `loyalty_card` SimpleLoyaltyCard, required — Simplified loyalty card data.
        - `points` integer, required — Total number of points added to the loyalty card over its lifespan.
        - `balance` integer — Points available for reward redemption. This is calculated as follows: `balance` = `points` - `expired_points` - `subtracted_points` - `redemption.redeemed_points`.
        - `next_expiration_date` string — The next closest date when the next set of points are due to expire.
        - `next_expiration_points` integer — The amount of points that are set to expire next.
        - `pending_points` integer — Shows the number of pending points that will be added to the loyalty card when they are activated automatically or manually.
        - `expired_points` integer — Shows the total number of expired points over the lifetime of the loyalty card.
        - `subtracted_points` integer — Shows the total number of subtracted points over the lifetime of the loyalty card.
    - VoucherImportGift — Object model for gift card object being imported.
      - `code` string, required — Value representing the imported code.
      - `redemption` object — Stores the quantity of redemptions that can be applied to the voucher.
        - `quantity` integer — How many times a voucher can be redeemed. A `null` value means unlimited.
      - `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](/api-reference/vouchers/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
      - `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
      - `validity_timeframe` ValidityTimeframe — 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`.
        - `duration` string — 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.
        - `interval` string — 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.
      - `validity_day_of_week` 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` 'GIFT_VOUCHER' — Defines the type of the voucher.
      - `gift` Gift, required — Contains current gift card balance information.
        - `amount` number, required — 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`.
        - `subtracted_amount` integer — Total amount of subtracted credits over the gift card lifetime.
        - `balance` number, required — Available funds. The value is multiplied by 100 to represent 2 decimal places. For example `10000 cents` for `$100.00`. `balance` = `amount` - `subtracted_amount` - `redemption.redeemed_amount`.
        - `effect` 'APPLY_TO_ORDER' | 'APPLY_TO_ITEMS' — Defines how the credits are applied to the customer's order.
    - VoucherImportDiscount — Object model for gift card object being imported.
      - `code` string, required — Value representing the imported code.
      - `redemption` object — Stores the quantity of redemptions that can be applied to the voucher.
        - `quantity` integer — How many times a voucher can be redeemed. A `null` value means unlimited.
      - `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](/api-reference/vouchers/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
      - `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
      - `validity_timeframe` ValidityTimeframe — 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`.
        - `duration` string — 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.
        - `interval` string — 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.
      - `validity_day_of_week` 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` 'DISCOUNT_VOUCHER' — Defines the type of the voucher.
      - `discount` union, required — Contains information about discount.
        - object
          - `type` 'AMOUNT', required — Defines the type of the voucher.
          - `amount_off` number, required — 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.
          - `amount_off_formula` string — Formula used to dynamically calculate the discount.
          - `aggregated_amount_limit` integer — Maximum discount amount per order.
          - `effect` 'APPLY_TO_ORDER' | 'APPLY_TO_ITEMS' | 'APPLY_TO_ITEMS_PROPORTIONALLY' | 'APPLY_TO_ITEMS_PROPORTIONALLY_BY_QUANTITY' | 'APPLY_TO_ITEMS_BY_QUANTITY'
          - `is_dynamic` boolean — Flag indicating whether the discount was calculated using a formula.
        - object
          - `type` 'UNIT', required — Discount type.
          - `unit_off` integer — Number of units to be granted a full value discount.
          - `unit_off_formula` string — Formula used to dynamically calculate the number of units.
          - `effect` 'ADD_MISSING_ITEMS' | 'ADD_NEW_ITEMS' | 'ADD_MANY_ITEMS' | 'ADD_SAME_ITEMS'
          - `unit_type` string, required — The product deemed as free, chosen from product inventory (e.g. time, items).
          - `product` SimpleProductDiscountUnit
            - `id` string, required — Unique product ID, assigned by Voucherify.
            - `source_id` string — Product's source ID.
            - `name` string, required — Product name.
          - `sku` SimpleSkuDiscountUnit
            - `id` string, required — Unique SKU ID, assigned by Voucherify.
            - `source_id` string — Product variant's source ID.
            - `name` string, required — Sku name
          - `is_dynamic` boolean — Flag indicating whether the discount was calculated using a formula.
        - object
          - `type` 'UNIT', required — Discount type.
          - `effect` 'ADD_MANY_ITEMS' — Defines how the discount is applied to the customer's order.
          - `units` DiscountUnitMultipleOneUnit[], required
            - `unit_off` number — Number of units to be granted a full value discount.
            - `unit_off_formula` string — Formula used to dynamically calculate the number of units.
            - `effect` 'ADD_NEW_ITEMS' | 'ADD_MISSING_ITEMS', required — Defines how the unit is added to the customer's order.
            - `unit_type` string, required — The product deemed as free, chosen from product inventory (e.g. time, items).
            - `product` SimpleProductDiscountUnit
              - …
            - `sku` SimpleSkuDiscountUnit
              - …
        - object
          - `type` 'PERCENT', required — Defines the type of the voucher.
          - `percent_off` number, required — The percent discount that the customer will receive.
          - `percent_off_formula` string — Formula used to dynamically calculate the discount.
          - `amount_limit` number — Upper limit allowed to be applied as a discount. Value is multiplied by 100 to precisely represent 2 decimal places. For example, a $6 maximum discount is written as 600.
          - `aggregated_amount_limit` integer — Maximum discount amount per order.
          - `effect` 'APPLY_TO_ORDER' | 'APPLY_TO_ITEMS'
          - `is_dynamic` boolean — Flag indicating whether the discount was calculated using a formula.
        - object
          - `type` 'FIXED', required — Defines the type of the voucher.
          - `fixed_amount` number, required — Sets a fixed value for an order total or the item price. The value is multiplied by 100 to precisely represent 2 decimal places. For example, a $10 discount is written as 1000. If the fixed amount is calculated by the formula, i.e. the `fixed_amount_formula` parameter is present in the fixed amount definition, this value becomes the **fallback value**. As a result, if the formula cannot be calculated due to missing metadata, for example, this value will be used as the fixed value.
          - `fixed_amount_formula` string — Formula used to dynamically calculate the discount.
          - `effect` 'APPLY_TO_ORDER' | 'APPLY_TO_ITEMS'
          - `is_dynamic` boolean — Flag indicating whether the discount was calculated using a formula.

## Response `202`

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](/api-reference/async-actions/get-async-action) endpoint.

- CampaignsImportCreateResponseBody — Response to requests that are processed asynchronously.
  - `async_action_id` string, required — The ID of the scheduled asynchronous action.

## Other responses

- `400` — Returns an error if the request includes incorrect data, e.g. a wrong data type or duplicated codes.

---

[API](https://skmtc.net/voucherifyio/apis/voucherify-api-async-actions.md) · [All operations](https://skmtc.net/voucherifyio/apis/voucherify-api-async-actions/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/voucherifyio/voucherify-api-async-actions/revisions/4982266e0494/schema)
