# Batch redeem promotions

- Operation ID: `BatchRedeemPromotions`
- HTTP method: `POST`
- Path: `/v4/promotions/promotion/batch-redeem`
- [Human-readable API reference](https://hub.synerise.com/api-reference/loyalty-and-engagement#tag/Promotions/operation/BatchRedeemPromotions)

## 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/promotions/promotion/batch-redeem:
    post:
      tags:
        - Promotions
      summary: Batch redeem promotions
      description: |
        You can redeem up to 100 promotions and loyalty points relevant to them.

        ---

        **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:** `PROMOTIONS_BATCH_REDEEM_PROMOTIONS_CREATE`

        **User role permission required:** `campaigns_promotions: create`
      operationId: BatchRedeemPromotions
      requestBody:
        content:
          application/json:
            schema:
              type: array
              minItems: 1
              maxItems: 200
              items:
                required:
                  - code
                  - clientKey
                  - clientKeyValue
                type: object
                properties:
                  code:
                    type: string
                    example: 75d9090f-06ac-46a2-a0ce-4b8eb287efb9
                    description: Promotion code
                  clientKey:
                    type: string
                    example: clientId
                    description: Type of profile identifier
                    enum:
                      - externalId
                      - clientId
                      - email
                      - phone
                      - uuid
                  clientKeyValue:
                    description: Value of the selected identifier
                    type: string
                    example: "434428563"
                  quantity:
                    description: Quantity of redeemed items
                    type: integer
                    example: 2
                    default: 1
                  sourceId:
                    description: "The source of redemption. It should be unique for the source of promotion to ensure that redemptions are successfully deduplicated when retried. Example: a concatenation of receipt ID and index of the discounted transaction line on the receipt."
                    type: string
                    example: 3f0a1670-eb63-43f1-a6b8-895a74621964-3
                  orderId:
                    description: Receipt ID for which the promotion was redeemed. It's required when using step promotions. The order ID will be used to check if requirements of granting a step promotion are fulfilled.
                    type: string
                    example: 3f0a1670-eb63-43f1-a6b8-895a74621964
                  lockIdentifier:
                    description: Identifier of the "promotion requested" lock which will be released when the promotion is redeemed. This kind of lock blocks a profile from requesting new promotions and can be applied when using the [Get Profile promotions by a custom filter](#operation/GetClientPromotionsByACustomFilter) endpoint.
                    type: string
                    example: 6561d87b-2697-46ad-8f9a-0550736b86e3
                example:
                  code: 75d9090f-06ac-46a2-a0ce-4b8eb287efb9
                  clientKey: clientId
                  clientKeyValue: "434428563"
        required: true
      responses:
        "201":
          description: Promotion redeemed successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Short summary of the response
              example:
                message: Promotion redeemed successfully
        "209":
          description: Promotion is already redeemed
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Short summary of the response
              example:
                message: Promotion is already redeemed
        "400":
          description: Request body invalid/malformed/missing elements
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    title: JSON content issue
                    properties:
                      message:
                        type: string
                        description: Summary of the error
                      error:
                        description: Details of the error
                        anyOf:
                          - type: array
                            description: An array of objects with error details
                            items:
                              type: object
                              description: Details of an error
                              properties:
                                message:
                                  type: string
                                  description: Short description of the error
                                  example: Internal Error
                                additionalProperties:
                                  description: Additional information, if applicable
                          - type: string
                            description: Description of the error
                  - type: object
                    title: JSON structure issue
                    properties:
                      message:
                        type: string
                        description: Summary of the error
                      code:
                        type: string
                        description: String-type code of the error
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    description: HTTP code of the problem
                  error:
                    type: string
                    description: Summary of the error
                  message:
                    type: string
                    description: Error details
                  timestamp:
                    type: string
                    description: Time when the error occurred
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    description: HTTP code of the problem
                  error:
                    type: string
                    description: Summary of the error
                  message:
                    type: string
                    description: Error details
                  timestamp:
                    type: string
                    description: Time when the error occurred
        "404":
          description: Not found error
          content:
            application/json:
              schema:
                anyOf:
                  - description: Profile not found
                    properties:
                      message:
                        type: string
                        description: Error details
                    example:
                      message: Profile not found
                  - description: Promotion not found
                    properties:
                      message:
                        type: string
                        description: Error details
                    example:
                      message: Promotion not found
        "409":
          description: Waiting for profile lock release
          content:
            application/json:
              schema:
                type: object
                title: JSON content issue
                properties:
                  message:
                    type: string
                    description: Summary of the error
                  error:
                    description: Details of the error
                    anyOf:
                      - type: array
                        description: An array of objects with error details
                        items:
                          type: object
                          description: Details of an error
                          properties:
                            message:
                              type: string
                              description: Short description of the error
                              example: Internal Error
                            additionalProperties:
                              description: Additional information, if applicable
                      - type: string
                        description: Description of the error
        "412":
          description: Unprocessable redemption
          content:
            application/json:
              schema:
                anyOf:
                  - description: Promotion not activated
                    properties:
                      message:
                        type: string
                        description: Error details
                    example:
                      message: Promotion not activated
                  - description: Promotion redeem limit exceeded
                    properties:
                      message:
                        type: string
                        description: Error details
                    example:
                      message: Promotion redeem limit exceeded
                  - description: Promotion already redeemed
                    properties:
                      message:
                        type: string
                        description: Error details
                    example:
                      message: Promotion already redeemed
        "423":
          description: Profile promotions blocked
          content:
            application/json:
              schema:
                type: object
                title: JSON content issue
                properties:
                  message:
                    type: string
                    description: Summary of the error
                  error:
                    description: Details of the error
                    anyOf:
                      - type: array
                        description: An array of objects with error details
                        items:
                          type: object
                          description: Details of an error
                          properties:
                            message:
                              type: string
                              description: Short description of the error
                              example: Internal Error
                            additionalProperties:
                              description: Additional information, if applicable
                      - type: string
                        description: Description of the error
      deprecated: false
      security:
        - JWT: []
      x-snr-doc-urls:
        - /api-reference/loyalty-and-engagement#tag/Promotions/operation/BatchRedeemPromotions
      x-codeSamples:
        - lang: cURL
          label: cURL
          source: |-
            curl --request POST \
              --url https://api.synerise.com/v4/promotions/promotion/batch-redeem \
              --header 'Authorization: Bearer REPLACE_BEARER_TOKEN' \
              --header 'content-type: application/json' \
              --data '[{"code":"75d9090f-06ac-46a2-a0ce-4b8eb287efb9","clientKey":"clientId","clientKeyValue":"434428563"}]'
        - lang: Python
          label: Python
          source: |-
            import http.client

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

            payload = "[{\"code\":\"75d9090f-06ac-46a2-a0ce-4b8eb287efb9\",\"clientKey\":\"clientId\",\"clientKeyValue\":\"434428563\"}]"

            headers = {
                'Authorization': "Bearer REPLACE_BEARER_TOKEN",
                'content-type': "application/json"
                }

            conn.request("POST", "/v4/promotions/promotion/batch-redeem", payload, headers)

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

            print(data.decode("utf-8"))
        - lang: JavaScript
          label: JavaScript
          source: |-
            const data = JSON.stringify([
              {
                "code": "75d9090f-06ac-46a2-a0ce-4b8eb287efb9",
                "clientKey": "clientId",
                "clientKeyValue": "434428563"
              }
            ]);

            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/promotions/promotion/batch-redeem");
            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/promotions/promotion/batch-redeem",
              "headers": {
                "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([
              {
                code: '75d9090f-06ac-46a2-a0ce-4b8eb287efb9',
                clientKey: 'clientId',
                clientKeyValue: '434428563'
              }
            ]));
            req.end();
        - lang: PHP
          label: PHP
          source: |-
            <?php

            $request = new HttpRequest();
            $request->setUrl('https://api.synerise.com/v4/promotions/promotion/batch-redeem');
            $request->setMethod(HTTP_METH_POST);

            $request->setHeaders([
              'Authorization' => 'Bearer REPLACE_BEARER_TOKEN',
              'content-type' => 'application/json'
            ]);

            $request->setBody('[{"code":"75d9090f-06ac-46a2-a0ce-4b8eb287efb9","clientKey":"clientId","clientKeyValue":"434428563"}]');

            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/promotions/promotion/batch-redeem")
              .header("Authorization", "Bearer REPLACE_BEARER_TOKEN")
              .header("content-type", "application/json")
              .body("[{\"code\":\"75d9090f-06ac-46a2-a0ce-4b8eb287efb9\",\"clientKey\":\"clientId\",\"clientKeyValue\":\"434428563\"}]")
              .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: Promotions
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.
```
