# Bulk create vouchers

- Operation ID: `BulkCreateVouchers`
- HTTP method: `POST`
- Path: `/v4/vouchers/item/bulk-create`
- [Human-readable API reference](https://hub.synerise.com/api-reference/loyalty-and-engagement#tag/Vouchers/operation/BulkCreateVouchers)

## Self-contained OpenAPI method

The fenced document below contains this method's documentation and all of its local references. It is self-contained; no category or master specification fetch is required.

```yaml
openapi: 3.0.0
info:
  title: Synerise Public API
  version: 1.9.1
paths:
  /v4/vouchers/item/bulk-create:
    post:
      tags:
        - Vouchers
      summary: Bulk create vouchers
      description: |
        Create a number of codes and add them to a pool.

        <span style="color:red"><strong>WARNING:</strong></span> The request body cannot contain more than 10 000 items or exceed 10 MB in size.

        ---

        **API consumers:** <a href="/api-reference/authorization?tag=Authorization&amp;operationId=profileLogin" target="_blank" rel="noopener">Workspace (Business Profile)</a>, <a href="/api-reference/authorization?tag=Authorization&amp;operationId=userLogin" target="_blank" rel="noopener">Synerise User</a>

        **API key permission required:** `VOUCHERS_ITEM_BULK_CREATE`

        **User role permission required:** `assets_code_pool: create`
      operationId: BulkCreateVouchers
      parameters:
        - name: Accept
          in: header
          required: true
          style: simple
          explode: false
          schema:
            type: string
            enum:
              - application/json
        - name: Content-Type
          in: header
          required: true
          style: simple
          explode: false
          schema:
            type: string
            enum:
              - application/json
        - name: Api-Version
          in: header
          required: true
          style: simple
          explode: false
          schema:
            type: string
            enum:
              - "4.4"
              - "4.2"
      requestBody:
        content:
          application/json:
            schema:
              required:
                - poolUuid
                - codeList
              type: object
              properties:
                poolUuid:
                  type: string
                  description: UUID of the voucher pool
                  example: faec32b0-c343-4362-ba32-c6148c649da4
                codeList:
                  type: string
                  description: A list of unique voucher codes, separated by semicolons
                  example: 3845734682364756454534;384574634564545456;567868678345234346748
      responses:
        "201":
          description: Vouchers created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    properties:
                      message:
                        type: string
                        default: Create object with success
                      data:
                        type: object
                        properties:
                          vouchersCreated:
                            type: integer
                            description: Number of created vouchers
                            example: 3
                          duplicatedCodes:
                            type: array
                            items:
                              type: string
                              example: code123
                            description: Codes which are duplicated (already exists for given workspace) and was ignored while creating vouchers
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                required:
                  - message
                  - error
                type: object
                properties:
                  message:
                    type: string
                    description: Description of the problem
                    example: Out of scope. Pool is empty.
                  error:
                    type: array
                    items:
                      type: object
                      properties:
                        field:
                          type: string
                          description: Name of the field that cause the problem (if applicable)
                          example: code
                        message:
                          type: string
                          example: code must be unique
                          description: Details of the problem
                        validatorKey:
                          type: string
                          example: not_unique
                          description: System ID of the problem (if applicable)
                    description: Details of the problem
              example:
                message: Data format is not valid
                error:
                  - field: code
                    message: code must be unique
                    validatorKey: not_unique
      deprecated: false
      security:
        - JWT: []
      x-snr-doc-urls:
        - /api-reference/loyalty-and-engagement#tag/Vouchers/operation/BulkCreateVouchers
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.synerise.com/v4/vouchers/item/bulk-create \
              --header 'Accept: SOME_STRING_VALUE' \
              --header 'Api-Version: SOME_STRING_VALUE' \
              --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
              --header 'Content-Type: SOME_STRING_VALUE' \
              --header 'content-type: application/json' \
              --data '{"poolUuid":"faec32b0-c343-4362-ba32-c6148c649da4","codeList":"3845734682364756454534;384574634564545456;567868678345234346748"}'
        - lang: Python
          label: Python
          source: |-
            import http.client

            conn = http.client.HTTPSConnection("api.synerise.com")

            payload = "{\"poolUuid\":\"faec32b0-c343-4362-ba32-c6148c649da4\",\"codeList\":\"3845734682364756454534;384574634564545456;567868678345234346748\"}"

            headers = {
                'Accept': "SOME_STRING_VALUE",
                'Content-Type': "SOME_STRING_VALUE",
                'Api-Version': "SOME_STRING_VALUE",
                'Authorization': "Bearer REPLACE_BEARER_TOKEN",
                'content-type': "application/json"
                }

            conn.request("POST", "/v4/vouchers/item/bulk-create", payload, headers)

            res = conn.getresponse()
            data = res.read()

            print(data.decode("utf-8"))
        - lang: JavaScript
          label: JavaScript
          source: |-
            const data = JSON.stringify({
              "poolUuid": "faec32b0-c343-4362-ba32-c6148c649da4",
              "codeList": "3845734682364756454534;384574634564545456;567868678345234346748"
            });

            const xhr = new XMLHttpRequest();
            xhr.withCredentials = true;

            xhr.addEventListener("readystatechange", function () {
              if (this.readyState === this.DONE) {
                console.log(this.responseText);
              }
            });

            xhr.open("POST", "https://api.synerise.com/v4/vouchers/item/bulk-create");
            xhr.setRequestHeader("Accept", "SOME_STRING_VALUE");
            xhr.setRequestHeader("Content-Type", "SOME_STRING_VALUE");
            xhr.setRequestHeader("Api-Version", "SOME_STRING_VALUE");
            xhr.setRequestHeader("Authorization", "Bearer REPLACE_BEARER_TOKEN");
            xhr.setRequestHeader("content-type", "application/json");

            xhr.send(data);
        - lang: Node.js
          label: Node.js
          source: |-
            const http = require("https");

            const options = {
              "method": "POST",
              "hostname": "api.synerise.com",
              "port": null,
              "path": "/v4/vouchers/item/bulk-create",
              "headers": {
                "Accept": "SOME_STRING_VALUE",
                "Content-Type": "SOME_STRING_VALUE",
                "Api-Version": "SOME_STRING_VALUE",
                "Authorization": "Bearer REPLACE_BEARER_TOKEN",
                "content-type": "application/json"
              }
            };

            const req = http.request(options, function (res) {
              const chunks = [];

              res.on("data", function (chunk) {
                chunks.push(chunk);
              });

              res.on("end", function () {
                const body = Buffer.concat(chunks);
                console.log(body.toString());
              });
            });

            req.write(JSON.stringify({
              poolUuid: 'faec32b0-c343-4362-ba32-c6148c649da4',
              codeList: '3845734682364756454534;384574634564545456;567868678345234346748'
            }));
            req.end();
        - lang: PHP
          label: PHP
          source: |-
            <?php

            $request = new HttpRequest();
            $request->setUrl('https://api.synerise.com/v4/vouchers/item/bulk-create');
            $request->setMethod(HTTP_METH_POST);

            $request->setHeaders([
              'Accept' => 'SOME_STRING_VALUE',
              'Content-Type' => 'SOME_STRING_VALUE',
              'Api-Version' => 'SOME_STRING_VALUE',
              'Authorization' => 'Bearer REPLACE_BEARER_TOKEN',
              'content-type' => 'application/json'
            ]);

            $request->setBody('{"poolUuid":"faec32b0-c343-4362-ba32-c6148c649da4","codeList":"3845734682364756454534;384574634564545456;567868678345234346748"}');

            try {
              $response = $request->send();

              echo $response->getBody();
            } catch (HttpException $ex) {
              echo $ex;
            }
        - lang: Java
          label: Java
          source: |-
            HttpResponse<String> response = Unirest.post("https://api.synerise.com/v4/vouchers/item/bulk-create")
              .header("Accept", "SOME_STRING_VALUE")
              .header("Content-Type", "SOME_STRING_VALUE")
              .header("Api-Version", "SOME_STRING_VALUE")
              .header("Authorization", "Bearer REPLACE_BEARER_TOKEN")
              .header("content-type", "application/json")
              .body("{\"poolUuid\":\"faec32b0-c343-4362-ba32-c6148c649da4\",\"codeList\":\"3845734682364756454534;384574634564545456;567868678345234346748\"}")
              .asString();
servers:
  - description: Microsoft Azure EU
    url: https://api.synerise.com
  - description: Microsoft Azure USA
    url: https://api.azu.synerise.com
  - description: Google Cloud Platform
    url: https://api.geb.synerise.com
tags:
  - name: Vouchers
components:
  securitySchemes:
    JWT:
      type: http
      scheme: bearer
      description: |-
        JWT Bearer token. The header looks like this: `Bearer {JWT}`

        Remember to include the space between 'Bearer' and the token.

        Generate a token via the **Authorization** endpoints.
```
