# Create a Coupon

## OpenAPI Specification

```yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1/coupons:
    post:
      summary: Create a Coupon
      deprecated: false
      description: ''
      tags:
        - API Reference/Coupons
      parameters:
        - name: Accept
          in: header
          description: ''
          required: true
          example: application/json
          schema:
            type: string
        - name: Content-Type
          in: header
          description: ''
          required: true
          example: application/json
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              x-apifox-refs:
                01JER5XS0HA3A9SEFVN3EW7C02: &ref_0
                  $ref: '#/components/schemas/Coupons'
                  x-apifox-overrides:
                    id: null
                    duration_in_months: null
                    duration_in_weeks: null
                    duration_in_days: null
                    object: null
                    created: null
                    livemode: null
                    max_redemptions: null
                    redeem_by: null
                    times_redeemed: null
                    valid: null
                    currency_options: null
                    applies_to: null
              x-apifox-orders:
                - 01JER5XS0HA3A9SEFVN3EW7C02
              properties:
                amount_off:
                  type: integer
                  description: >-
                    Amount (in the currency specified) that will be taken off
                    the subtotal of any invoices for this customer.
                  nullable: true
                currency:
                  type: string
                  description: >-
                    If amount_off has been set, the three-letter ISO code for
                    the currency of the amount to take off.
                  nullable: true
                duration:
                  type: string
                  description: >-
                    One of forever, once, and repeating. Describes how long a
                    customer who applies this coupon will get the discount.
                  enum:
                    - forever
                    - once
                    - repeating
                  x-apifox-enum:
                    - value: forever
                      name: ''
                      description: >-
                        Applies to all charges from a subscription with this
                        coupon applied.
                    - value: once
                      name: ''
                      description: >-
                        Applies to the first charge from a subscription with
                        this coupon applied.
                    - value: repeating
                      name: ''
                      description: >-
                        Applies to charges in the first duration_in_months
                        months from a subscription with this coupon applied.
                metadata:
                  type: object
                  properties: {}
                  x-apifox-orders: []
                  description: >-
                    Set of key-value pairs that you can attach to an object.
                    This can be useful for storing additional information about
                    the object in a structured format.
                  x-apifox-ignore-properties: []
                name:
                  type: string
                  description: >-
                    Name of the coupon displayed to customers on for instance
                    invoices or receipts.
                percent_off:
                  type: number
                  description: >-
                    Percent that will be taken off the subtotal of any invoices
                    for this customer for the duration of the coupon. For
                    example, a coupon with percent_off of 50 will make a $100
                    invoice $50 instead.
                  nullable: true
              x-apifox-ignore-properties:
                - amount_off
                - currency
                - duration
                - metadata
                - name
                - percent_off
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                x-apifox-refs:
                  01JER5ZBBTD6TCXBBJSZY0TZKJ: *ref_0
                x-apifox-orders:
                  - 01JER5ZBBTD6TCXBBJSZY0TZKJ
                properties:
                  id:
                    type: string
                    description: Unique identifier for the object.
                  amount_off:
                    type: integer
                    description: >-
                      Amount (in the currency specified) that will be taken off
                      the subtotal of any invoices for this customer.
                    nullable: true
                  currency:
                    type: string
                    description: >-
                      If amount_off has been set, the three-letter ISO code for
                      the currency of the amount to take off.
                    nullable: true
                  duration:
                    type: string
                    description: >-
                      One of forever, once, and repeating. Describes how long a
                      customer who applies this coupon will get the discount.
                    enum:
                      - forever
                      - once
                      - repeating
                    x-apifox-enum:
                      - value: forever
                        name: ''
                        description: >-
                          Applies to all charges from a subscription with this
                          coupon applied.
                      - value: once
                        name: ''
                        description: >-
                          Applies to the first charge from a subscription with
                          this coupon applied.
                      - value: repeating
                        name: ''
                        description: >-
                          Applies to charges in the first duration_in_months
                          months from a subscription with this coupon applied.
                  object:
                    type: string
                    description: >-
                      String representing the object’s type. Objects of the same
                      type share the same value.
                  created:
                    type: integer
                    description: >-
                      Time at which the object was created. Measured in seconds
                      since the Unix epoch.
                  livemode:
                    type: boolean
                    description: >-
                      Has the value true if the object exists in live mode or
                      the value false if the object exists in test mode.
                  metadata:
                    type: object
                    properties: {}
                    x-apifox-orders: []
                    description: >-
                      Set of key-value pairs that you can attach to an object.
                      This can be useful for storing additional information
                      about the object in a structured format.
                    x-apifox-ignore-properties: []
                  name:
                    type: string
                    description: >-
                      Name of the coupon displayed to customers on for instance
                      invoices or receipts.
                  percent_off:
                    type: number
                    description: >-
                      Percent that will be taken off the subtotal of any
                      invoices for this customer for the duration of the coupon.
                      For example, a coupon with percent_off of 50 will make a
                      $100 invoice $50 instead.
                    nullable: true
                x-apifox-ignore-properties:
                  - id
                  - amount_off
                  - currency
                  - duration
                  - object
                  - created
                  - livemode
                  - metadata
                  - name
                  - percent_off
          headers: {}
          x-apifox-name: OK
      security:
        - basic: []
      x-apifox-folder: API Reference/Coupons
      x-apifox-status: released
      x-run-in-apifox: https://app.apifox.com/web/project/1296482/apis/api-159748782-run
components:
  schemas:
    Coupons:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the object.
        amount_off:
          type: integer
          description: >-
            Amount (in the currency specified) that will be taken off the
            subtotal of any invoices for this customer.
          nullable: true
        currency:
          type: string
          description: >-
            If amount_off has been set, the three-letter ISO code for the
            currency of the amount to take off.
          nullable: true
        duration:
          type: string
          description: >-
            One of forever, once, and repeating. Describes how long a customer
            who applies this coupon will get the discount.
          enum:
            - forever
            - once
            - repeating
          x-apifox-enum:
            - value: forever
              name: ''
              description: >-
                Applies to all charges from a subscription with this coupon
                applied.
            - value: once
              name: ''
              description: >-
                Applies to the first charge from a subscription with this coupon
                applied.
            - value: repeating
              name: ''
              description: >-
                Applies to charges in the first duration_in_months months from a
                subscription with this coupon applied.
        duration_in_months:
          type: integer
          description: >-
            Required only if duration is repeating, in which case it must be a
            positive integer that specifies the number of months the discount
            will be in effect.
        duration_in_weeks:
          type: string
          description: >-
            Required only if duration is repeating, in which case it must be a
            positive integer that specifies the number of weeks the discount
            will be in effect.
        duration_in_days:
          type: string
          description: >-
            Required only if duration is repeating, in which case it must be a
            positive integer that specifies the number of weeks the discount
            will be in effect.
        object:
          type: string
          description: >-
            String representing the object’s type. Objects of the same type
            share the same value.
        created:
          type: integer
          description: >-
            Time at which the object was created. Measured in seconds since the
            Unix epoch.
        livemode:
          type: boolean
          description: >-
            Has the value true if the object exists in live mode or the value
            false if the object exists in test mode.
        metadata:
          type: object
          properties: {}
          x-apifox-orders: []
          description: >-
            Set of key-value pairs that you can attach to an object. This can be
            useful for storing additional information about the object in a
            structured format.
          x-apifox-ignore-properties: []
        name:
          type: string
          description: >-
            Name of the coupon displayed to customers on for instance invoices
            or receipts.
        percent_off:
          type: number
          description: >-
            Percent that will be taken off the subtotal of any invoices for this
            customer for the duration of the coupon. For example, a coupon with
            percent_off of 50 will make a $100 invoice $50 instead.
          nullable: true
        max_redemptions:
          type: integer
          description: >-
            Maximum number of times this coupon can be redeemed, in total,
            across all customers, before it is no longer valid.
          nullable: true
        redeem_by:
          type: integer
          description: Date after which the coupon can no longer be redeemed.
          nullable: true
        times_redeemed:
          type: integer
          description: Number of times this coupon has been applied to a customer.
        valid:
          type: boolean
          description: >-
            Taking account of the above properties, whether this coupon can
            still be applied to a customer.
        applies_to:
          type: object
          properties:
            products:
              type: array
              items:
                type: string
              description: A list of product IDs this coupon applies to
          description: Contains information about what this coupon applies to.
          x-apifox-orders:
            - products
          x-apifox-ignore-properties: []
        currency_options:
          type: object
          properties:
            <currency>.amount_off:
              type: integer
              description: >-
                Amount (in the currency specified) that will be taken off the
                subtotal of any invoices for this customer.
          description: >-
            Coupons defined in each available currency option. Each key must be
            a three-letter ISO currency code and a supported currency.
          x-apifox-orders:
            - <currency>.amount_off
          x-apifox-ignore-properties: []
      x-apifox-orders:
        - id
        - amount_off
        - currency
        - duration
        - duration_in_months
        - duration_in_weeks
        - duration_in_days
        - object
        - created
        - livemode
        - metadata
        - name
        - percent_off
        - max_redemptions
        - redeem_by
        - times_redeemed
        - valid
        - applies_to
        - currency_options
      required:
        - duration_in_weeks
        - duration_in_days
      x-apifox-ignore-properties: []
      x-apifox-folder: ''
  securitySchemes:
    basic:
      type: http
      scheme: basic
servers:
  - url: https://apitest.wooshpay.com
    description: 官网测试
security:
  - basic: []

```
