> ## 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 using CSV

> Import generic (standalone) vouchers into the repository using a CSV file.

The CSV file has to include headers in the first line. All properties listed in the file headers that cannot be mapped to standard voucher fields will be added to the metadata object.
You can upload up to 100,000 codes to a campaign, as a campaign can have up to 100,000 codes by default. 
 Also, the request can include a max. **10 MB** CSV file.

You can find an example CSV file [here](/build/discount-code-import).
___

```cURL cURL example
curl -X **POST** \
  https://api.voucherify.io/v1/vouchers/importCSV \
  -F file=@/path/to/vouchers.csv \
  -F webhooks_enable=true\
  -H "X-App-Id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
  -H "X-App-Token: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
```



> 📘 Standard voucher fields mapping
>
> - Go to the [import vouchers](/api-reference/vouchers/import-vouchers) endpoint to see all standard CSV fields description (body params section).
> - Supported CSV file headers: Code,Voucher Type,Value,Discount Type,Category,Start Date,Expiration Date,Redemption Limit,Redeemed Quantity, Redeemed Amount,Active,Additional Info,Custom Metadata Property Name
>- **Start and expiration dates** need to be provided in compliance with the ISO 8601 standard. For example, 2020-03-11T09:00:00.000Z.  
>    - `YYYY-MM-DD`
>    - `YYYY-MM-DDTHH`
>    - `YYYY-MM-DDTHH:mm`
>    - `YYYY-MM-DDTHH:mm:ss`
>    - `YYYY-MM-DDTHH:mm:ssZ`
>    - `YYYY-MM-DDTHH:mm:ssZ`
>    - `YYYY-MM-DDTHH:mm:ss.SSSZ`
> - Custom code attributes (not supported by-default) need to be added as code **metadata**.
> - You **cannot import the same codes** to a single Voucherify project.
> - You can, however, upload the same codes to update them.



> 📘 Categories
>
> In the structure representing your data, you can define a category that the voucher belongs to. You can later use the category of a voucher to group and search by specific criteria in the Dashboard and using the [List Vouchers](/api-reference/vouchers/list-vouchers) endpoint.

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

You can pass the `webhooks_enable=true` parameter to trigger a webhook sendout for created or updated vouchers. Configure the [respective webhooks](/api-reference/introduction-to-webhooks) in Project settings. For updated webhooks, a webhook is sent even if the voucher hasn't been changed in the CSV file.

>🚧 Generic (standalone) vouchers and campaigns
>
>In version [v20241004](https://support.voucherify.io/article/23-whats-new-in-voucherify#v20241004), generic (standalone) vouchers created through the Voucherify dashboard create a campaign for that voucher. However, vouchers imported through the dashboard in the Vouchers section or through the API do not have a campaign attached, so the values for `campaign` and `campaign_id` are `null`.



## OpenAPI

````yaml /openapi/vouchers.json post /v1/vouchers/importCSV
openapi: 3.0.1
info:
  title: Voucherify API - Vouchers
  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/vouchers/importCSV:
    post:
      tags:
        - Vouchers
      summary: Import Vouchers using CSV
      description: >-
        Import generic (standalone) vouchers into the repository using a CSV
        file.


        The CSV file has to include headers in the first line. All properties
        listed in the file headers that cannot be mapped to standard voucher
        fields will be added to the metadata object.

        You can upload up to 100,000 codes to a campaign, as a campaign can have
        up to 100,000 codes by default. 
         Also, the request can include a max. **10 MB** CSV file.

        You can find an example CSV file [here](/build/discount-code-import).

        ___


        ```cURL cURL example

        curl -X **POST** \
          https://api.voucherify.io/v1/vouchers/importCSV \
          -F file=@/path/to/vouchers.csv \
          -F webhooks_enable=true\
          -H "X-App-Id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
          -H "X-App-Token: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        ```




        > 📘 Standard voucher fields mapping

        >

        > - Go to the [import vouchers](/api-reference/vouchers/import-vouchers)
        endpoint to see all standard CSV fields description (body params
        section).

        > - Supported CSV file headers: Code,Voucher Type,Value,Discount
        Type,Category,Start Date,Expiration Date,Redemption Limit,Redeemed
        Quantity, Redeemed Amount,Active,Additional Info,Custom Metadata
        Property Name

        >- **Start and expiration dates** need to be provided in compliance with
        the ISO 8601 standard. For example, 2020-03-11T09:00:00.000Z.  

        >    - `YYYY-MM-DD`

        >    - `YYYY-MM-DDTHH`

        >    - `YYYY-MM-DDTHH:mm`

        >    - `YYYY-MM-DDTHH:mm:ss`

        >    - `YYYY-MM-DDTHH:mm:ssZ`

        >    - `YYYY-MM-DDTHH:mm:ssZ`

        >    - `YYYY-MM-DDTHH:mm:ss.SSSZ`

        > - Custom code attributes (not supported by-default) need to be added
        as code **metadata**.

        > - You **cannot import the same codes** to a single Voucherify project.

        > - You can, however, upload the same codes to update them.




        > 📘 Categories

        >

        > In the structure representing your data, you can define a category
        that the voucher belongs to. You can later use the category of a voucher
        to group and search by specific criteria in the Dashboard and using the
        [List Vouchers](/api-reference/vouchers/list-vouchers) endpoint.


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


        You can pass the `webhooks_enable=true` parameter to trigger a webhook
        sendout for created or updated vouchers. Configure the [respective
        webhooks](/api-reference/introduction-to-webhooks) in Project settings.
        For updated webhooks, a webhook is sent even if the voucher hasn't been
        changed in the CSV file.


        >🚧 Generic (standalone) vouchers and campaigns

        >

        >In version
        [v20241004](https://support.voucherify.io/article/23-whats-new-in-voucherify#v20241004),
        generic (standalone) vouchers created through the Voucherify dashboard
        create a campaign for that voucher. However, vouchers imported through
        the dashboard in the Vouchers section or through the API do not have a
        campaign attached, so the values for `campaign` and `campaign_id` are
        `null`.
      operationId: import-vouchers-using-csv
      parameters: []
      requestBody:
        description: The file path is stored in the form `file` header.
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/VouchersImportCSVRequestBody'
        required: true
      responses:
        '202':
          description: >-
            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](/api-reference/async-actions/get-async-action) endpoint.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VouchersImportCsvCreateResponseBody'
              examples:
                Example:
                  value:
                    async_action_id: aa_0a875d56c805df6601
        '400':
          description: >-
            Invalid payload. You may receive this error if you have incorrectly
            or have not specified the content type as `multipart/form-data` in
            the headers.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Example 1:
                  value:
                    code: 400
                    key: invalid_payload
                    message: Invalid payload
                    details: Payload should have required property 'file'
                    request_id: 74e4bb71-5b6d-49b9-98eb-239691c9d67a
      security:
        - X-App-Id: []
          X-App-Token: []
        - X-Voucherify-OAuth:
            - api
            - vouchers
components:
  schemas:
    VouchersImportCSVRequestBody:
      type: object
      title: Vouchers Import CSV Request Body
      description: Request body schema for **POST** `v1/vouchers/importCSV`.
      allOf:
        - $ref: '#/components/schemas/ImportCSVRequestBody'
        - type: object
          properties:
            webhooks_enable:
              type: boolean
              description: >-
                Triggers a webhook sendout for new and updated vouchers if the
                voucher created and voucher updated webhooks are configured in
                Project settings.
    VouchersImportCsvCreateResponseBody:
      type: object
      title: Vouchers Import Csv Create Response Body
      description: Response body schema for **POST** `v1/vouchers/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
  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`.

````