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

# 创建优惠券

> Create a coupon and optionally create promotion codes for it.



## OpenAPI

````yaml POST /coupon
openapi: 3.1.0
info:
  title: Clink API
  description: >-
    Official API documentation for Clink's payment processing platform. This API
    enables merchants to create and manage payment sessions, handle
    subscriptions, and process transactions.
  version: 1.0.0
servers:
  - url: https://uat-api.clinkbill.com/api/
security:
  - ApiKeyAuth: []
paths:
  /coupon:
    post:
      summary: Create Coupon
      description: Create a coupon and optionally create promotion codes for it.
      operationId: createCoupon
      parameters:
        - $ref: '#/components/parameters/TimestampHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CouponCreateRequest'
            examples:
              percentageCoupon:
                summary: Percentage coupon
                value:
                  couponName: Summer Sale
                  discountType: percentage
                  percentage: 20
                  applyType: product
                  applicableProducts:
                    - prd_xxxxx
                  durationType: once
                  maxRedemptionCount: 100
                  validPeriodStart: 1780660800000
                  validPeriodEnd: 1783252800000
                  promotionCodes:
                    - code: SUMMER2026
                      maxRedemptionLimit: 100
              fixedAmountCoupon:
                summary: Fixed amount coupon
                value:
                  couponName: USD 5 Off
                  discountType: fixed_amount
                  fixedAmounts:
                    USD: 5
                  applyType: none
                  durationType: forever
      responses:
        '200':
          description: Coupon created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RApiCouponInfoResponse'
            '*/*':
              schema:
                $ref: '#/components/schemas/RApiCouponInfoResponse'
        '401':
          description: Unauthorized
          content:
            '*/*':
              schema:
                type: string
components:
  parameters:
    TimestampHeader:
      name: X-Timestamp
      in: header
      required: true
      description: >-
        Current timestamp in milliseconds since Unix epoch (required for request
        signing)
      schema:
        type: string
        example: '1783513683000'
  schemas:
    CouponCreateRequest:
      type: object
      description: Parameters required to create a coupon
      required:
        - couponName
        - discountType
        - applyType
        - durationType
      properties:
        couponName:
          type: string
          maxLength: 40
          description: Coupon name
        discountType:
          type: string
          description: Discount type
          enum:
            - percentage
            - fixed_amount
        percentage:
          type: number
          minimum: 0
          maximum: 100
          description: Percentage discount. Used when discountType is percentage.
        fixedAmounts:
          type: object
          description: >-
            Fixed discount amount by currency. Used when discountType is
            fixed_amount.
          additionalProperties:
            type: number
          example:
            USD: 5
            EUR: 4.5
        applyType:
          type: string
          description: Coupon applicability type
          enum:
            - none
            - product
            - price
        applicableProducts:
          type: array
          description: Product IDs this coupon applies to
          items:
            type: string
        applicablePrices:
          type: object
          description: Price IDs this coupon applies to, grouped by product ID
          additionalProperties:
            type: array
            items:
              type: string
        durationType:
          type: string
          description: Discount duration type
          enum:
            - once
            - repeating
            - forever
        durationMonths:
          type: integer
          format: int32
          description: Number of billing periods for repeating coupons
        maxRedemptionCount:
          type: integer
          format: int32
          description: Maximum total redemptions for this coupon
        validPeriodStart:
          type: integer
          format: int64
          description: >-
            Coupon validity start time as a 13-digit Unix timestamp in
            milliseconds
          example: 1780660800000
        validPeriodEnd:
          type: integer
          format: int64
          description: >-
            Coupon validity end time as a 13-digit Unix timestamp in
            milliseconds
          example: 1780660800000
        promotionCodes:
          type: array
          maxItems: 20
          description: Promotion codes to create together with the coupon
          items:
            $ref: '#/components/schemas/PromotionCodeCreateRequest'
    RApiCouponInfoResponse:
      type: object
      properties:
        code:
          type: integer
          description: Response status code, 200 when success
          format: int32
          example: 200
        msg:
          type: string
          example: success
          description: Brief description of what happened, 'success' when happy case
        data:
          $ref: '#/components/schemas/ApiCouponInfoResponse'
      description: Body of the response message
    PromotionCodeCreateRequest:
      type: object
      description: Parameters required to create a promotion code
      properties:
        code:
          type: string
          description: >-
            Customer-facing promotion code. If omitted, a code can be generated
            by the platform.
          pattern: ^[a-zA-Z0-9]{1,32}$
          example: SUMMER2026
        firstOrderOnly:
          type: boolean
          description: Whether this promotion code is limited to first orders only
        restrictedCustomerIds:
          type: array
          description: >-
            Customer IDs allowed to redeem this promotion code. Empty means
            unrestricted.
          items:
            type: string
        minimumSpend:
          type: object
          description: Minimum spend by currency. Key is an ISO currency code.
          additionalProperties:
            type: number
          example:
            USD: 10
            EUR: 9
        perCustomerRedemptionLimit:
          type: integer
          format: int32
          description: Redemption limit per customer
        maxRedemptionLimit:
          type: integer
          format: int32
          description: Maximum total redemptions for this promotion code
        validPeriodStart:
          type: integer
          format: int64
          description: >-
            Promotion code validity start time as a 13-digit Unix timestamp in
            milliseconds
          example: 1780660800000
        validPeriodEnd:
          type: integer
          format: int64
          description: >-
            Promotion code validity end time as a 13-digit Unix timestamp in
            milliseconds
          example: 1780660800000
    ApiCouponInfoResponse:
      type: object
      properties:
        couponId:
          type: string
          description: Unique identifier of the coupon
        couponName:
          type: string
          description: Coupon name
        discountType:
          type: string
          description: Discount type
          enum:
            - percentage
            - fixed_amount
        percentage:
          type: number
          description: Percentage discount
        fixedAmounts:
          type: object
          description: Fixed discount amount by currency
          additionalProperties:
            type: number
        durationType:
          type: string
          description: Discount duration type
          enum:
            - once
            - repeating
            - forever
        durationMonths:
          type: integer
          format: int32
          description: Number of billing periods for repeating coupons
        maxRedemptionCount:
          type: integer
          format: int32
          description: Maximum total redemptions for this coupon
        redeemedCount:
          type: integer
          format: int32
          description: Number of times this coupon has been redeemed
        validPeriodEnd:
          type: integer
          format: int64
          description: >-
            Coupon validity end time as a 13-digit Unix timestamp in
            milliseconds
          example: 1754819711382
        mirroring:
          type: boolean
          description: Whether this record is mirrored data
        terms:
          type: string
          description: Human-readable coupon terms
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
      description: >-
        Your secret API key obtained from the Clink dashboard (Developers
        section)

````