# Count vouchers

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

## 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/count/{poolUuid}:
    post:
      tags:
        - Vouchers
      summary: Count vouchers
      description: |
        Count (re-calculate) vouchers in a pool, group the results by status.

        ---

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

        **User role permission required:** `assets_code_pool: read`
      operationId: getVouchersCount
      parameters:
        - name: poolUuid
          in: path
          description: UUID of the voucher pool
          required: true
          style: simple
          explode: false
          schema:
            type: string
            example: 8465c240-d38e-42f8-af29-b9fa1ed05115
        - 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"
      responses:
        "200":
          description: Set of counters
          content:
            application/json:
              schema:
                required:
                  - data
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      assignedCount:
                        type: integer
                        format: int32
                        example: 130
                        description: Number of assigned vouchers
                      activeCount:
                        type: integer
                        format: int32
                        example: 130
                        description: Number of active vouchers
                      countAt:
                        type: string
                        format: date-time
                        description: Time when the calculation was made
      security:
        - JWT: []
      x-snr-doc-urls:
        - /api-reference/loyalty-and-engagement#tag/Vouchers/operation/getVouchersCount
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.synerise.com/v4/vouchers/item/count/8465c240-d38e-42f8-af29-b9fa1ed05115 \
              --header 'Accept: SOME_STRING_VALUE' \
              --header 'Api-Version: SOME_STRING_VALUE' \
              --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
              --header 'Content-Type: SOME_STRING_VALUE'
        - lang: Python
          label: Python
          source: |-
            import http.client

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

            headers = {
                'Accept': "SOME_STRING_VALUE",
                'Content-Type': "SOME_STRING_VALUE",
                'Api-Version': "SOME_STRING_VALUE",
                'Authorization': "Bearer REPLACE_BEARER_TOKEN"
                }

            conn.request("POST", "/v4/vouchers/item/count/8465c240-d38e-42f8-af29-b9fa1ed05115", headers=headers)

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

            print(data.decode("utf-8"))
        - lang: JavaScript
          label: JavaScript
          source: |-
            const data = null;

            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/count/8465c240-d38e-42f8-af29-b9fa1ed05115");
            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.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/count/8465c240-d38e-42f8-af29-b9fa1ed05115",
              "headers": {
                "Accept": "SOME_STRING_VALUE",
                "Content-Type": "SOME_STRING_VALUE",
                "Api-Version": "SOME_STRING_VALUE",
                "Authorization": "Bearer REPLACE_BEARER_TOKEN"
              }
            };

            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.end();
        - lang: PHP
          label: PHP
          source: |-
            <?php

            $request = new HttpRequest();
            $request->setUrl('https://api.synerise.com/v4/vouchers/item/count/8465c240-d38e-42f8-af29-b9fa1ed05115');
            $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'
            ]);

            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/count/8465c240-d38e-42f8-af29-b9fa1ed05115")
              .header("Accept", "SOME_STRING_VALUE")
              .header("Content-Type", "SOME_STRING_VALUE")
              .header("Api-Version", "SOME_STRING_VALUE")
              .header("Authorization", "Bearer REPLACE_BEARER_TOKEN")
              .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.
```
