# Create a voucher pool

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

## 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/pool:
    post:
      tags:
        - Vouchers
      summary: Create a voucher pool
      description: |
        Create a pool for voucher storage.

        ---

        **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_POOL_CREATE`

        **User role permission required:** `assets_code_pool: create`
      operationId: CreateAVoucherPool
      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:
                - name
                - expireIn
              type: object
              properties:
                name:
                  type: string
                  description: Name of the voucher pool
                description:
                  type: string
                  description: A description of the pool
                startAt:
                  type: string
                  format: date-time
                  description: Time when the pool starts functioning. Defaults to current time.
                expireIn:
                  type: string
                  format: date-time
                  description: Time when the pool stops functioning. Must be later than `startAt`.
        required: true
      responses:
        "201":
          description: Pool created
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    default: Create object with success
                  data:
                    type: object
                    description: Voucher pool details. Alongside the properties listed here the payload still carries `barcodeType`, `voucherPrefix`, `poolLimit`, `redeemedLimitPerClient` and `lastingTime`. They are stored and returned for backward compatibility, drive no behaviour in the service, and may be removed — new integrations should not rely on them.
                    properties:
                      uuid:
                        type: string
                        description: UUID of the voucher pool
                        example: 8465c240-d38e-42f8-af29-b9fa1ed05115
                      name:
                        type: string
                        description: Name of the voucher pool
                      description:
                        type: string
                        description: A description of the pool
                      startAt:
                        type: string
                        format: date-time
                        description: Time when the pool starts functioning. Defaults to current time.
                      expireIn:
                        type: string
                        format: date-time
                        description: Time when the pool stops functioning. Must be later than `startAt`.
                      userId:
                        type: integer
                        format: int32
                        description: ID of the User who created the pool
                      assignedCount:
                        type: integer
                        format: int32
                        description: Number of assigned vouchers. **To refresh the counter, use [this endpoint](#operation/getVouchersCount).**
                      activeCount:
                        type: integer
                        format: int32
                        description: Number of active vouchers. **To refresh the counter, use [this endpoint](#operation/getVouchersCount).**
                      countAt:
                        type: string
                        format: date-time
                        description: Time when the counters were last calculated
      deprecated: false
      security:
        - JWT: []
      x-snr-doc-urls:
        - /api-reference/loyalty-and-engagement#tag/Vouchers/operation/CreateAVoucherPool
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.synerise.com/v4/vouchers/pool \
              --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 '{"name":"string","description":"string","startAt":"2019-08-24T14:15:22Z","expireIn":"2019-08-24T14:15:22Z"}'
        - lang: Python
          label: Python
          source: |-
            import http.client

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

            payload = "{\"name\":\"string\",\"description\":\"string\",\"startAt\":\"2019-08-24T14:15:22Z\",\"expireIn\":\"2019-08-24T14:15:22Z\"}"

            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/pool", payload, headers)

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

            print(data.decode("utf-8"))
        - lang: JavaScript
          label: JavaScript
          source: |-
            const data = JSON.stringify({
              "name": "string",
              "description": "string",
              "startAt": "2019-08-24T14:15:22Z",
              "expireIn": "2019-08-24T14:15:22Z"
            });

            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/pool");
            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/pool",
              "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({
              name: 'string',
              description: 'string',
              startAt: '2019-08-24T14:15:22Z',
              expireIn: '2019-08-24T14:15:22Z'
            }));
            req.end();
        - lang: PHP
          label: PHP
          source: |-
            <?php

            $request = new HttpRequest();
            $request->setUrl('https://api.synerise.com/v4/vouchers/pool');
            $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('{"name":"string","description":"string","startAt":"2019-08-24T14:15:22Z","expireIn":"2019-08-24T14:15:22Z"}');

            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/pool")
              .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("{\"name\":\"string\",\"description\":\"string\",\"startAt\":\"2019-08-24T14:15:22Z\",\"expireIn\":\"2019-08-24T14:15:22Z\"}")
              .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.
```
