> ## Documentation Index
> Fetch the complete documentation index at: https://docs.voucherify.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Import Vouchers to Campaign by CSV

> Imports vouchers to an **existing** campaign.  


The CSV file has to include headers in the first line. 

Curl Example

```cURL
curl -X **POST** \
  https://api.voucherify.io/v1/campaigns/TEST-CAMPAIGN/importCSV \
  -F file=@/path/to/campaigns.csv \
  -H "X-App-Id: c70a6f00-cf91-4756-9df5-47628850002b" \
  -H "X-App-Token: 3266b9f8-e246-4f79-bdf0-833929b1380c"
```

You can import values for the following fields: `Code` (**required**), `Category`, `Active`. In a gift cards import, you can also include the current card balance using the `Gift Amount` header and the amount that was redeemed using the `Redeemed Amount` header. In a loyalty cards import, you can also include the current loyalty card score in points using the `Loyalty Points` header. Remaining CSV columns will be mapped to metadata properties. 

Discount type, time limits, and validation rules will be taken from the [campaign object](/api-reference/campaigns/campaign-object) settings. 


| **Active** | **Code** | **Loyalty Points** | **Gift Amount** | **Redeemed Amount** | **Redeemed Quantity** | **Category** | **Custom_metadata_property** |
|---|---|---|---|---|---|---|---|
| Use `true` or `false` to enable or disable the voucher; this flag can be used to turn off the ability to redeem a voucher even though it is within the campaign's start/end validity timeframe. | The unique voucher code. | The number of points to be added to the loyalty card. If you leave this undefined, then the initial number of points will be set according to the campaign settings.<br />Context: `LOYALTY_PROGRAM` | The initial gift card balance.<br />Context: `GIFT_VOUCHERS` | The amount that was redeemed from the available balance on a gift card. | The number of times the voucher has been redeemed. | A custom tag for the voucher to help you filter codes; you can either import the category name or a unique Voucherify-assigned category ID. | Any additional data that you would like to store for the given loyalty card as a Custom attribute. Remember to define the metadata schema in the Dashboard prior to importing codes. |
|

> 📘 Active
>
> The CSV file is allowed in two versions; either with or without a column titled `Active`. It indicates whether the voucher is enabled after the import event.  

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



## OpenAPI

````yaml /openapi/campaigns.json post /v1/campaigns/{campaignId}/importCSV
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}/importCSV:
    parameters:
      - schema:
          $ref: '#/components/schemas/ParameterCampaignId'
        name: campaignId
        in: path
        required: true
        description: >-
          The campaign ID or name of the campaign being enabled. 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 by CSV
      description: >-
        Imports vouchers to an **existing** campaign.  



        The CSV file has to include headers in the first line. 


        Curl Example


        ```cURL

        curl -X **POST** \
          https://api.voucherify.io/v1/campaigns/TEST-CAMPAIGN/importCSV \
          -F file=@/path/to/campaigns.csv \
          -H "X-App-Id: c70a6f00-cf91-4756-9df5-47628850002b" \
          -H "X-App-Token: 3266b9f8-e246-4f79-bdf0-833929b1380c"
        ```


        You can import values for the following fields: `Code` (**required**),
        `Category`, `Active`. In a gift cards import, you can also include the
        current card balance using the `Gift Amount` header and the amount that
        was redeemed using the `Redeemed Amount` header. In a loyalty cards
        import, you can also include the current loyalty card score in points
        using the `Loyalty Points` header. Remaining CSV columns will be mapped
        to metadata properties. 


        Discount type, time limits, and validation rules will be taken from the
        [campaign object](/api-reference/campaigns/campaign-object) settings. 



        | **Active** | **Code** | **Loyalty Points** | **Gift Amount** |
        **Redeemed Amount** | **Redeemed Quantity** | **Category** |
        **Custom_metadata_property** |

        |---|---|---|---|---|---|---|---|

        | Use `true` or `false` to enable or disable the voucher; this flag can
        be used to turn off the ability to redeem a voucher even though it is
        within the campaign's start/end validity timeframe. | The unique voucher
        code. | The number of points to be added to the loyalty card. If you
        leave this undefined, then the initial number of points will be set
        according to the campaign settings.<br />Context: `LOYALTY_PROGRAM` |
        The initial gift card balance.<br />Context: `GIFT_VOUCHERS` | The
        amount that was redeemed from the available balance on a gift card. |
        The number of times the voucher has been redeemed. | A custom tag for
        the voucher to help you filter codes; you can either import the category
        name or a unique Voucherify-assigned category ID. | Any additional data
        that you would like to store for the given loyalty card as a Custom
        attribute. Remember to define the metadata schema in the Dashboard prior
        to importing codes. |

        |


        > 📘 Active

        >

        > The CSV file is allowed in two versions; either with or without a
        column titled `Active`. It indicates whether the voucher is enabled
        after the import event.  


        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-using-csv
      parameters: []
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/CampaignsVouchersImportCSVRequestBody'
        description: The file path is stored in the form `file` header.
        required: true
      responses:
        '200':
          description: >-
            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.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CampaignsImportCsvCreateResponseBody'
              examples:
                Example:
                  $ref: '#/components/examples/res_async_actions'
        '404':
          description: Returns an error if the campaign cannot be found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Example:
                  value:
                    code: 404
                    key: not_found
                    message: Resource not found
                    details: Cannot find campaign with id camp_FZL4iTTdZw36nZOoXYQ172fQ
                    request_id: v-0bc26adad888b6fed1
                    resource_id: camp_FZL4iTTdZw36nZOoXYQ172fQ
                    resource_type: campaign
      security:
        - X-App-Id: []
          X-App-Token: []
        - X-Voucherify-OAuth:
            - api
            - campaigns
components:
  schemas:
    ParameterCampaignId:
      type: string
      example: camp_rRsfatlwN7unSeUIJDCYedal
    CampaignsVouchersImportCSVRequestBody:
      type: object
      title: Campaigns Vouchers Import CSV Request Body
      description: Request body schema for **POST** `v1/campaigns/{campaignId}/importCSV`.
      allOf:
        - $ref: '#/components/schemas/ImportCSVRequestBody'
    CampaignsImportCsvCreateResponseBody:
      type: object
      title: Campaigns Import Csv Create Response Body
      description: Response body schema for **POST** `v1/campaigns/{campaignId}/importCSV`.
      allOf:
        - $ref: '#/components/schemas/AsyncActions'
    Error:
      title: Error Object
      type: object
      description: Error details
      properties:
        code:
          type: integer
          description: Error's HTTP status code.
        key:
          type: string
          description: Short string describing the kind of error which occurred.
        message:
          type: string
          description: A human-readable message providing a short description of the error.
        details:
          type: string
          description: A human-readable message providing more details about the error.
        request_id:
          type: string
          example: v-0a885062c80375740f
          description: >-
            This ID is useful when troubleshooting and/or finding the root cause
            of an error response by our support team.
        resource_id:
          type: string
          description: >-
            Unique resource ID that can be used in another endpoint to get more
            details.
          example: rf_0c5d710a87c8a31f86
        resource_type:
          type: string
          description: The resource type.
          example: voucher
        error:
          type: object
          description: Includes additional information about the error.
          properties:
            message:
              type: string
              description: The message configured by the user in a validation rule.
      required:
        - code
        - message
    ImportCSVRequestBody:
      type: object
      title: Import CSV file
      description: Request body schema for importing data using a CSV file.
      format: binary
      properties:
        file:
          type: string
          format: binary
          description: File path.
      required:
        - file
    AsyncActions:
      type: object
      title: Asynchronous Actions
      description: Response to requests that are processed asynchronously.
      properties:
        async_action_id:
          type: string
          example: aa_0a875d56c805df6601
          description: The ID of the scheduled asynchronous action.
      required:
        - async_action_id
  examples:
    res_async_actions:
      value:
        async_action_id: aa_0ab2df092385be5ca5
  securitySchemes:
    X-App-Id:
      type: apiKey
      name: X-App-Id
      in: header
    X-App-Token:
      type: apiKey
      name: X-App-Token
      in: header
    X-Voucherify-OAuth:
      type: oauth2
      flows:
        implicit:
          authorizationUrl: https://api.voucherify.io/v1/oauth/token
          scopes:
            api: Gives access to whole server-side API.
            vouchers: >-
              Gives access to all endpoints and methods starting with
              `v1/vouchers`.
            client_api: Gives access to whole client-side API.
            client_vouchers: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/vouchers`.
            promotions: >-
              Gives access to all endpoints and methods starting with
              `/v1/promotions`.
            client_promotions: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/promotions`
            campaigns: >-
              Gives access to all endpoints and methods starting with
              `v1/campaigns`.
            client_publish: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/publish`.
            exports: >-
              Gives access to all endpoints and methods starting with
              `/v1/exports`.
            publications: >-
              Gives access to all endpoints and methods starting with
              `/v1/publications`.
            client_validate: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/validate`.
            validations: >-
              Gives access to all endpoints and methods starting with
              `/v1/validations`.
            client_validations: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/validations`.
            qualifications: >-
              Gives access to all endpoints and methods starting with
              `/v1/qualifications`.
            client_qualifications: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/qualifications`.
            client_redeem: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/redeem
            redemptions: >-
              Gives access to all endpoints and methods starting with
              `/v1/redemptions`.
            client_redemptions: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/redemptions`
            customers: >-
              Gives access to all endpoints and methods starting with
              `/v1/customers`.
            client_customers: >-
              Gives access to all endpoints and methods starting with
              `/client/v1/customers`.
            orders: >-
              Gives access to all endpoints and methods starting with
              `/v1/orders`.
            products: >-
              Gives access to all endpoints and methods starting with
              `/v1/products`.
            skus: >-
              Gives access to all endpoints and methods starting with
              `/v1/SKUs`.
            validation-rules: >-
              Gives access to all endpoints and methods starting with
              `/v1/validation-rules`.
            validation-rules-assignments: >-
              Gives access to all endpoints and methods starting with
              `/v1/validation-rules-assignments
            segments: >-
              Gives access to all endpoints and methods starting with
              `/v1/segments`.
            events: >-
              Gives access to all endpoints and methods starting with
              `/v1/events`.
            client_events: >-
              Gives access to all endpoints and methods starting with
              `client/v1/events`.
            rewards: >-
              Gives access to all endpoints and methods starting with
              `/v1/rewards`.
            assets: >-
              Gives access to all endpoints and methods starting with
              `/v1/assets`.
            task-results: >-
              Gives access to all endpoints and methods starting with
              `/v1/task-results`.
            loyalties: >-
              Gives access to all endpoints and methods starting with
              `/v1/loyalties`.
            client_consents: >-
              Gives access to all endpoints and methods starting with
              `client/v1/consents`.
            consents: >-
              Gives access to all endpoints and methods starting with
              `/v1/consents`.
            async-actions: >-
              Gives access to all endpoints and methods starting with
              `/v1/async-actions`.
            product-collections: >-
              Gives access to all endpoints and methods starting with
              `/v1/product-collections`.
            categories: >-
              Gives access to all endpoints and methods starting with
              `/v1/categories`.
            metadata-schemas: >-
              Gives access to all endpoints and methods starting with
              `/v1/metadata-schemas`.
            locations: >-
              Gives access to all endpoints and methods starting with
              `/v1/locations`.
            referrals: >-
              Gives access to all endpoints and methods starting with
              `/v1/referrals`.
            trash-bin: >-
              Gives access to all endpoints and methods starting with
              `/v1/trash-bin`.
            templates: >-
              Gives access to all endpoints and methods starting with
              `/v1/templates`.

````