> ## Documentation Index
> Fetch the complete documentation index at: https://docs.appcharge.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Bulk Create Promo Codes

> Creates multiple promo codes for a specific coupon.

Maximum of 1,000 promo codes allowed per request.


<RequestExample>
  ```bash Bulk Create Promo Codes theme={"system"}
  curl -X POST \
    'https://api.appcharge.com/coupons/coupon/summer26/promo-codes' \
    -H 'Content-Type: application/json' \
    -H 'x-publisher-token: <x-publisher-token>' \
    -d '{
      "promoCodes": [
          {
              "name": "swx1",
              "maxRedemptions": 1,
              "active": true
          },
          {
              "name": "swx2",
              "maxRedemptions": 1,
              "active": true
          }
      ]
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json Bulk Create Promo Codes theme={"system"}
  {
      "promoCodes": [
          {
              "name": "swx1",
              "active": true,
              "maxRedemptions": 1,
              "createdAt": "2025-01-22T15:58:24.116Z",
              "updatedAt": "2025-01-25T08:44:26.668Z"
          },
          {
              "name": "swx2",
              "active": true,
              "maxRedemptions": 1,
              "createdAt": "2025-01-22T15:58:24.116Z",
              "updatedAt": "2025-01-25T08:44:26.668Z"
          }
      ]
  }
  ```

  ```json 400 theme={"system"}
  {
      "error": "Invalid coupon name. Use only English letters and numbers."
  }
  ```

  ```json 400 theme={"system"}
  {
      "error": "Invalid promo code name. Use only English letters and numbers."
  }
  ```

  ```json 400 theme={"system"}
  {
      "error": "Promo codes count must be at least 1."
  }
  ```

  ```json 400 theme={"system"}
  {
      "error": "Promo codes count must not exceed 1000."
  }
  ```

  ```json 400 theme={"system"}
  {
      "error": "Some promo codes in the request are duplicated: swx1, swx2."
  }
  ```

  ```json 400 theme={"system"}
  {
      "error": "maxRedemptions must not be less than 1."
  }
  ```

  ```json 400 theme={"system"}
  {
      "error": "Missing required field: promoCodes."
  }
  ```

  ```json 404 theme={"system"}
  {
      "error": "Coupon not found."
  }
  ```

  ```json 409 theme={"system"}
  {
      "error": "Some promo codes are already active on other coupon: swx1, swx2."
  }
  ```

  ```json 500 theme={"system"}
  {
      "error": "Unexpected error. Please contact support."
  }
  ```
</ResponseExample>


## OpenAPI

````yaml openapi-coupons.json post /coupons/coupon/{couponName}/promo-codes
openapi: 3.0.3
info:
  title: Coupons API
  version: 1.0.0
servers:
  - url: https://api.appcharge.com
security:
  - PublisherTokenAuth: []
tags:
  - name: Coupons
  - name: Promo Codes
paths:
  /coupons/coupon/{couponName}/promo-codes:
    parameters:
      - in: path
        name: couponName
        required: true
        schema:
          type: string
          example: summer26
        description: Coupon name.
    post:
      tags:
        - Promo Codes
      description: >-
        Creates multiple promo codes for a specific coupon. <br/><br/> Maximum
        of 1,000 promo codes allowed per request.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePromoCodesRequest'
      responses:
        '200':
          description: Promo codes created successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PromoCodesResponse'
        '400':
          description: Bad request. Invalid input or validation failure.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                invalidCouponName:
                  summary: Invalid coupon name
                  value:
                    error: Invalid coupon name. Use only English letters and numbers.
                invalidPromoCodeName:
                  summary: Invalid promo code name
                  value:
                    error: >-
                      Invalid promo code name. Use only English letters and
                      numbers.
                promoCodesBelowMinimum:
                  summary: Promo codes count below minimum
                  value:
                    error: Promo codes count must be at least 1.
                promoCodesAboveMaximum:
                  summary: Promo codes count above maximum
                  value:
                    error: Promo codes count must not exceed 1000.
                duplicatePromoCodes:
                  summary: Duplicate promo codes in request
                  value:
                    error: >-
                      Some promo codes in the request are duplicated: swx1,
                      swx2.
                maxRedemptionsBelowMinimum:
                  summary: maxRedemptions below minimum
                  value:
                    error: maxRedemptions must not be less than 1
                missingRequiredField:
                  summary: Required field missing
                  value:
                    error: 'Missing required field: promoCodes.'
        '404':
          description: Coupon not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                couponNotFound:
                  summary: Coupon not found
                  value:
                    error: Coupon not found.
        '409':
          description: >-
            Conflict. One or more promo codes already exist and are active on
            another coupon.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                promoCodeExists:
                  summary: Promo code already active on another coupon
                  value:
                    error: >-
                      Some promo codes are already active on other coupon: swx1,
                      swx2.
        '500':
          description: Unexpected error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                unexpectedError:
                  summary: Unexpected error
                  value:
                    error: Unexpected error. Please contact support.
components:
  schemas:
    CreatePromoCodesRequest:
      type: object
      properties:
        promoCodes:
          type: array
          items:
            $ref: '#/components/schemas/CreatePromoCodeInput'
          description: List of promo codes to create.
      required:
        - promoCodes
    PromoCodesResponse:
      type: object
      properties:
        promoCodes:
          type: array
          items:
            $ref: '#/components/schemas/CreatedPromoCode'
          description: List of created promo codes.
    Error:
      type: object
      properties:
        error:
          type: string
          description: Error message describing what went wrong.
    CreatePromoCodeInput:
      type: object
      properties:
        name:
          type: string
          description: Promo code name. Can't contain spaces or special characters.
          example: swx1
        maxRedemptions:
          type: integer
          description: Maximum number of times this promo code can be redeemed.
          example: 1
        active:
          type: boolean
          description: Whether the promo code is active.
          example: true
      required:
        - name
        - maxRedemptions
        - active
    CreatedPromoCode:
      type: object
      properties:
        name:
          type: string
          description: Promo code name.
          example: swx1
        active:
          type: boolean
          description: Whether the promo code is active.
          example: true
        maxRedemptions:
          type: integer
          description: Maximum number of times this promo code can be redeemed.
          example: 1
        createdAt:
          type: string
          format: date-time
          description: Timestamp when the promo code was created.
          example: '2025-01-22T15:58:24.116Z'
        updatedAt:
          type: string
          format: date-time
          description: Timestamp when the promo code was last updated.
          example: '2025-01-25T08:44:26.668Z'
  securitySchemes:
    PublisherTokenAuth:
      type: apiKey
      in: header
      name: x-publisher-token
      description: Publisher token, as displayed in the Publisher Dashboard.

````