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

# Create a coupon

> Create a coupon



## OpenAPI

````yaml openapi-billing.json POST /v1/coupons
openapi: 3.1.0
info:
  title: Yorlet Billing API
  description: APIs for managing invoices, coupons, credit grants, and subscription items.
  version: 1.0.0
servers:
  - url: https://api.yorlet.com
    description: Production
  - url: https://api.yorlet.io
    description: Sandbox
security: []
paths:
  /v1/coupons:
    post:
      tags:
        - Coupons
      summary: Create a coupon
      description: Create a coupon
      operationId: coupons_create
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                amount_off:
                  type: number
                  description: >-
                    A positive integer representing the amount to subtract from
                    an invoice total (required if `percent_off` is not passed).
                applies_to:
                  type: object
                  properties:
                    invoice_item_types:
                      type: array
                      items:
                        type: string
                        enum:
                          - rent
                          - charge
                          - product
                      description: The types of invoice items the coupon can be applied to.
                  description: >-
                    A hash containing directions for what this coupon will apply
                    discounts to.
                currency:
                  type: string
                  description: >-
                    Three-letter ISO code for the currency of the `amount_off`
                    parameter (required if `amount_off` is passed).
                duration:
                  type: string
                  enum:
                    - repeating
                    - once
                    - forever
                  description: >-
                    Specifies how long the discount will be in effect if used on
                    a subscription.
                duration_in_months:
                  type: number
                  minimum: 1
                  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.
                max_redemptions:
                  type: number
                  minimum: 1
                  description: >-
                    A positive integer specifying the number of times the coupon
                    can be redeemed before it is no longer valid.
                metadata:
                  type:
                    - object
                    - 'null'
                  additionalProperties:
                    type: string
                  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.
                name:
                  type: string
                  description: >-
                    Name of the coupon displayed to customers on, for instance,
                    invoices or receipts.
                percent_off:
                  type: number
                  minimum: 1
                  maximum: 100
                  description: >-
                    A positive float larger than 0, and smaller or equal to 100,
                    that represents the discount the coupon will apply (required
                    if `amount_off` is not passed).
                redeem_by:
                  type: integer
                  description: >-
                    Unix timestamp specifying the last time at which the coupon
                    can be redeemed.
              required:
                - name
      responses:
        '200':
          description: Create a coupon
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: Unique identifier for the object.
                  created:
                    type: number
                    description: >-
                      Time at which the object was created. Measured in seconds
                      since the Unix epoch.
                  account:
                    type: string
                    description: >-
                      The account that the object belongs to. Only returned if
                      the request is made with a valid Yorlet-Context header.
                  deleted:
                    type: boolean
                    default: false
                    description: Only returned if the object has been deleted.
                  object:
                    type: string
                    enum:
                      - coupon
                  amount_off:
                    type:
                      - number
                      - 'null'
                    description: >-
                      The fixed amount that will be taken off the subtotal of
                      any invoices for this customer.
                  applies_to:
                    type: object
                    properties:
                      invoice_item_types:
                        type:
                          - array
                          - 'null'
                        items:
                          type: string
                        description: >-
                          The types of invoice items the coupon can be applied
                          to.
                    required:
                      - invoice_item_types
                    description: Details on what the coupon can be applied to.
                  currency:
                    type: string
                    description: >-
                      Three-letter ISO currency code, in lowercase. Must be a
                      supported currency.
                  duration:
                    type:
                      - string
                      - 'null'
                    description: >-
                      Describes how long a customer who applies this coupon will
                      get the discount.
                  duration_in_months:
                    type:
                      - number
                      - 'null'
                    description: >-
                      If `duration` is `repeating`, the number of months the
                      coupon applies. Null if coupon does not have a duration in
                      months.
                  max_redemptions:
                    type:
                      - number
                      - 'null'
                    description: >-
                      Maximum number of times this coupon can be redeemed, in
                      total, before it is no longer valid.
                  metadata:
                    type:
                      - object
                      - 'null'
                    additionalProperties:
                      type: string
                    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.
                  name:
                    type:
                      - string
                      - 'null'
                    description: >-
                      Name of the coupon displayed to customers on, for
                      instance, invoices or receipts.
                  percent_off:
                    type:
                      - number
                      - 'null'
                    description: >-
                      Percent that will be taken off the subtotal of any
                      invoices for this customer for the duration of the coupon.
                  redeem_by:
                    type:
                      - number
                      - 'null'
                    description: Date after which the coupon can no longer be redeemed.
                  times_redeemed:
                    type: number
                    default: 0
                    description: >-
                      Number of times this coupon has been applied to a
                      customer.
                  valid:
                    type: boolean
                    description: >-
                      Whether the coupon is currently valid and can still be
                      redeemed.
                required:
                  - id
                  - created
                  - object
                  - amount_off
                  - applies_to
                  - currency
                  - duration
                  - duration_in_months
                  - max_redemptions
                  - metadata
                  - name
                  - percent_off
                  - redeem_by
                  - valid
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: API Key authentication. Use "Bearer YOUR_API_KEY".

````