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

# Create a coupon

> Creates a discount coupon that can be applied to subscriptions. The code must be unique within the company.



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/subscriptions/coupons
openapi: 3.0.0
info:
  title: PlugToPay API
  description: API to make payments easy in multiple gateways.
  version: 1.0.0
servers:
  - url: http://localhost:7701
    description: Test Server
security: []
paths:
  /api/v1/subscriptions/coupons:
    post:
      tags:
        - Coupons
      summary: Create a coupon
      description: >-
        Creates a discount coupon that can be applied to subscriptions. The code
        must be unique within the company.
      operationId: 34f9dc35456cfdf6ef8bcbcbe7d3a304
      parameters:
        - $ref: '#/components/parameters/XClientId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              required:
                - code
                - name
                - discount_type
                - discount_value
                - valid_from
              properties:
                code:
                  description: Unique alphanumeric code (max 50 chars). Case-sensitive.
                  type: string
                  example: SUMMER20
                name:
                  description: Display name for the coupon (max 255 chars).
                  type: string
                  example: 20% off Summer Sale
                description:
                  description: Optional description (max 1000 chars).
                  type: string
                  example: Applies to all monthly plans.
                  nullable: true
                discount_type:
                  description: How the discount is calculated.
                  type: string
                  enum:
                    - percentage
                    - fixed
                  example: percentage
                discount_value:
                  description: >-
                    Discount amount: percentage (1–100) when type is percentage;
                    cents when type is fixed.
                  type: integer
                  example: 20
                valid_from:
                  description: Date from which the coupon can be applied.
                  type: string
                  format: date
                  example: '2026-07-01'
                valid_until:
                  description: Expiry date (must be after valid_from). Null = no expiry.
                  type: string
                  format: date
                  example: '2026-08-31'
                  nullable: true
                max_redemptions:
                  description: >-
                    Maximum total uses across all subscriptions. Null =
                    unlimited.
                  type: integer
                  example: 100
                  nullable: true
                max_cycles:
                  description: >-
                    Maximum billing cycles the discount applies per
                    subscription. Null = applies forever.
                  type: integer
                  example: 3
                  nullable: true
              type: object
      responses:
        '201':
          description: Coupon created
          content:
            application/json:
              schema:
                properties:
                  data:
                    $ref: '#/components/schemas/Coupon'
                type: object
        '401':
          description: Unauthorized — Invalid API Key
        '422':
          description: Validation error or duplicate coupon code
      security:
        - ApiKeyAuth: []
components:
  parameters:
    XClientId:
      name: x-client-id
      in: header
      description: Client identifier for the company in the request.
      required: true
      schema:
        type: string
        example: client_abc123
  schemas:
    Coupon:
      properties:
        id:
          type: string
          format: uuid
        code:
          description: Alphanumeric coupon code (max 50 chars).
          type: string
          example: SUMMER20
        name:
          type: string
          example: 20% off Summer Sale
        description:
          type: string
          nullable: true
        discount_type:
          type: string
          enum:
            - percentage
            - fixed
          example: percentage
        discount_value:
          description: >-
            Percentage (1–100) when discount_type is percentage; cents when
            fixed.
          type: integer
          example: 20
        max_redemptions:
          description: Maximum total uses across all subscriptions. Null = unlimited.
          type: integer
          example: 100
          nullable: true
        redemptions_count:
          description: Number of times this coupon has been applied.
          type: integer
          example: 5
        max_cycles:
          description: >-
            Maximum billing cycles the discount applies per subscription. Null =
            forever.
          type: integer
          example: 3
          nullable: true
        valid_from:
          type: string
          format: date-time
          nullable: true
        valid_until:
          type: string
          format: date-time
          nullable: true
        is_active:
          type: boolean
          example: true
        created_at:
          type: string
          format: date-time
          nullable: true
      type: object
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      description: Company API key. Send in the X-API-Key header.
      name: X-API-Key
      in: header

````