# Create a coupon

`POST /coupons`

> This is a subset of the full specification, limited to the `POST /coupons` operation.
>
> You can find the full specification here: /_bundle/docs/dev-docs/api/index.yaml

```yaml
openapi: 3.1.1
info:
  version: latest
  title: Core APIs
  contact:
    name: Rebilly API Support
    url: https://www.rebilly.com/contact/
    email: integrations@rebilly.com
  license:
    name: Rebilly
    url: https://www.rebilly.com/api-license/
  termsOfService: https://www.rebilly.com/terms-of-use/
  x-logo:
    url: https://rebilly-core.redoc.ly/rb_apiLogo.svg
    backgroundColor: '#0044d4'
  description: This is a subset of the full specification, limited to the `POST /coupons` operation. Components more than 3 `$ref` hops away are not included.
  x-metadata:
    description: The most common APIs used to automate common workflows.
    redocly_category: API Reference
servers:
  - url: https://api-sandbox.rebilly.com/organizations/{organizationId}
    description: Sandbox server
    variables:
      organizationId:
        default: '{organizationId}'
        description: |-
          Unique organization identifier.
          An organization is an entity that represents a company.
          For more information, see [Obtain an organization ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
  - url: https://api.rebilly.com/organizations/{organizationId}
    description: Live server
    variables:
      organizationId:
        default: '{organizationId}'
        description: |-
          Unique organization identifier.
          An organization is an entity that represents a company.
          For more information, see [Obtain an organization ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
security:
  - SecretApiKey: []
  - JWT: []
tags:
  - name: Coupons
    description: |-
      Use coupons to reward customers, generate sales, or to test new pricing strategies.
      Use coupons to apply different types of discounts to invoices, subscriptions, and pricing plans.

      Redeemed coupons are attached to a customer's account.
      Depending on the coupon restrictions, the redeemed coupons are then applied from the customer's account to subsequent invoices or subscriptions.
      Redeemed coupons can only be applied to invoices of the same currency.

      After a coupon is redeemed, it cannot be modified.
      You may deactivate a coupon or create a new coupon, but you cannot reuse the same coupon code.
      If you have a use case where you must reuse the same code, [contact Rebilly](https://www.rebilly.com/contact/).

      ### Coupon restriction types

      The following coupon description types are available:

      - `restrict-to-countries`: Restricts a coupon for use in specific countries.
      - `discounts-per-redemption`: Restricts the number of times that the coupon can be applied by one redemption.
        For example, use this restriction to configure a coupon that can only be applied to the first subscription renewal of a particular product.
      - `minimum-order-amount`: Sets a minimum order amount for a coupon application.
        For example, if the restriction amount is $20, the coupon is only applied to invoices with a total amount of $20 or more.
      - `restrict-to-invoices`: Restricts a coupon to specific invoices.
      - `restrict-to-plans`: Restricts a coupon to specific pricing plans.
      - `restrict-to-subscriptions`: Restricts a coupon to specific order subscriptions.
      - `restrict-to-customer-tags`: Restricts a coupon to customers with specific tags.
      - `restrict-to-customers`: Restricts a coupon to specific customers.
      - `restrict-to-exclusive-application`: Restricts a coupon so that it cannot be used in combination with other coupons. If more than one coupon is active, a coupon with this restriction is only applied if it provides a larger discount than the other coupons combined. If a coupon with this restriction is applied, all other coupons are removed.
      - `restrict-to-products`: Restricts a coupon to specific products.
      - `paid-by-time`: Specifies a date and time at which a coupon redemption expires if not paid.
      - `redemptions-per-customer`: Restricts the number of times that a coupon can be redeemed by one customer.
        For example, use this restriction to limit the number of redemptions to one per customer.
      - `total-redemptions`: Restricts the number of times a coupon can be redeemed by different customers.
      - `restrict-to-bxgy`: Provides "buy X get Y" promotions.
        These promotions incentivize new customers to buy and also reward existing customers.
        Use this restriction type to add discounted plans to an invoice when a certain quantity of other plans are purchased.
        For example, if a customer buys two or more books, they get one free bookmark.
x-tagGroups:
  - name: Orders & Invoices
    tags:
      - Coupons
paths:
  /coupons:
    post:
      x-products:
        - Core
      tags:
        - Coupons
      summary: Create a coupon
      operationId: PostCoupon
      x-sdk-operation-name: create
      security:
        - SecretApiKey: []
        - JWT: []
        - ApplicationJWT: []
      description: Creates a coupon.
      requestBody:
        $ref: '#/components/requestBodies/Coupon'
      responses:
        '201':
          description: Coupon created.
          headers:
            Location:
              $ref: '#/components/headers/Location'
            Rate-Limit-Limit:
              $ref: '#/components/headers/Rate-Limit-Limit'
            Rate-Limit-Remaining:
              $ref: '#/components/headers/Rate-Limit-Remaining'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Coupon'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          $ref: '#/components/responses/ValidationError'
        '429':
          $ref: '#/components/responses/TooManyRequests'
      x-codeSamples:
        - lang: PHP
          label: PHP-SDK-2.0
          source: |
            $couponForm = new Rebilly\Entities\Coupons\Coupon();

            $discountArray = [
                'currency' => 'USD',
                'amount' => 1.99,
            ];

            $discountForm = new \Rebilly\Entities\Coupons\Discounts\Fixed($discountArray);
            $couponForm->setDiscount($discountForm);
            // Coupon can be used right now
            $couponForm->setIssuedTime(date('c'));

            $restrictionArray = [
                'quantity' => 2,
            ];

            $restrictionForm = new Rebilly\Entities\Coupons\Restrictions\DiscountsPerRedemption($restrictionArray);

            $couponForm->setRestrictions([$restrictionForm]);

            try {
                $coupon = $client->coupons()->create($couponForm);
            } catch (Rebilly\Http\Exception\DataValidationException $e) {
                print_r($e->getValidationErrors());
            }
        - lang: JavaScript
          source: |
            // first set the required properties for the new coupon
            const data = {
                description: 'a new coupon',
                issuedTime: '2017-09-19T20:46:44Z',
                discount: {
                    type: 'percent',
                    value: 12
                },
                restrictions: [{
                    type: 'discounts-per-redemption',
                    quantity: 12
                }]
            };

            // the ID is optional
            const firstKey = await api.coupons.create({data});

            // or you can provide one
            const secondKey = await api.coupons.create({id: 'my-second-id', data});
        - lang: PHP
          source: |-
            $service = new \Rebilly\Sdk\Service($client);

            $couponForm = new \Rebilly\Sdk\Model\Coupon();

            $discountForm = new \Rebilly\Sdk\Model\DiscountFixed();
            $discountForm->setCurrency('USD');
            $discountForm->setAmount(1.99);

            $couponForm->setDiscount($discountForm);
            // Coupon can be used right now
            $couponForm->setIssuedTime(date('c'));

            $restrictionArray = [
                'quantity' => 2,
            ];

            $restrictionForm = new \Rebilly\Sdk\Model\CouponRestrictionDiscountPerRedemption($restrictionArray);

            $couponForm->setRestrictions([$restrictionForm]);

            try {
                $coupon = $service->coupons()->create($couponForm);
            } catch (\Rebilly\Sdk\Exception\DataValidationException $e) {
                print_r($e->getValidationErrors());
            }
components:
  securitySchemes:
    JWT:
      description: |-
        JWT is a short lifetime token that can be assigned a specific expiration time.

        Usage format: `Bearer <JWT>`.
      type: http
      scheme: bearer
      bearerFormat: JWT
    ApplicationJWT:
      description: |-
        Applications in the Rebilly App Store can create a JSON Web Token (JWT) by fetching an user's instance.
        For more information, see Retrieve an application instance.

        Usage format: `Bearer <JWT>`.
      type: http
      scheme: bearer
      bearerFormat: JWT
    SecretApiKey:
      description: |-
        Never share your secret keys.
        Keep them guarded and secure.

        Use your secret API key only to make requests from the server side.
        To authenticate, provide your secret key in the request header.
      name: REB-APIKEY
      type: apiKey
      in: header
  headers:
    Location:
      description: Location of the related resource.
      schema:
        type: string
        format: uri
      example: https://api.rebilly.com/example
    Rate-Limit-Limit:
      description: |-
        Maximum number of requests available at one time for this rate limit.
        For more information, see [Rate limits](#section/Rate-limits).
      schema:
        type: integer
      example: 500
    Rate-Limit-Remaining:
      description: |-
        Number of requests still available for this rate limit.
        For more information, see [Rate limits](#section/Rate-limits).
      schema:
        type: integer
      example: 499
    Rate-Limit-Retry-After:
      description: Number of seconds to wait before retrying the request.
      schema:
        type: integer
      example: 1
  schemas:
    CreatedTime:
      type: string
      description: |-
        Date and time when the resource is created.
        This value is set automatically when the resource is created.
      format: date-time
      readOnly: true
      x-sortable: true
      x-label: Creation Time
    UpdatedTime:
      type: string
      description: |-
        Date and time when the resource is updated.
        This value is set automatically when the resource is updated.
      format: date-time
      readOnly: true
      x-sortable: true
      x-label: Last Update Time
    SelfLink:
      type: array
      description: Related links.
      readOnly: true
      items:
        type: object
        properties:
          href:
            description: Link URL.
            type: string
          rel:
            description: Type of link.
            type: string
            enum:
              - self
    BaseProblem:
      type: object
      additionalProperties: true
      minProperties: 1
      description: RFC-7807 [problem details](https://tools.ietf.org/html/rfc7807) JSON object.
      properties:
        type:
          type: string
          description: |-
            Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference.
            It should provide human-readable documentation for the problem type.
            When this member is not present, its value is assumed to be "about:blank".
          format: uri
        title:
          type: string
          description: |-
            Short, human-readable summary of the problem type.
            Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.
        detail:
          type: string
          description: Human-readable explanation that is specific to this occurrence of the problem.
        instance:
          type: string
          description: |-
            URI reference that identifies the specific occurrence of the problem.
            It may or may not yield further information if dereferenced.
    Unauthorized:
      allOf:
        - title: Unauthorized
        - type: object
          properties:
            status:
              type: integer
              description: HTTP status code.
              minimum: 401
              maximum: 401
        - $ref: '#/components/schemas/BaseProblem'
    OrganizationId:
      type: string
      description: |-
        Unique organization identifier.
        An organization is an entity that represents a company.
        For more information, see [Obtain an organization ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
      maxLength: 50
      example: org_0YVDM8RC7GDADADSBSMW124JA8
    Forbidden:
      allOf:
        - title: Forbidden
        - type: object
          properties:
            status:
              type: integer
              description: HTTP status code.
              minimum: 403
              maximum: 403
            error:
              type: string
              description: |-
                Message that describes why the request is forbidden.
                Most responses use a descriptive message, such as `Not allowed to change security settings`.
                If the organization requires multi-factor authentication (MFA) and MFA verification has not been completed for the session, this value is `mfa_required`.
                If MFA verification has not been completed for the session and the operation requires a confirmed session, this value is `mfa_required_for_caller`.
                This includes turning on `requireMfa` and resetting MFA for a user.
                If the organization restricts access to a list of IP addresses and the request comes from an IP address that is not in the list, this value is `ip_not_allowed`.
            organizationId:
              description: |-
                ID of the organization that requires MFA or does not allow the IP address of the request.
                This property is present only if `error` is `mfa_required` or `ip_not_allowed`.
                The organization is the organization of the request or another organization that the request acts on.
              $ref: '#/components/schemas/OrganizationId'
        - $ref: '#/components/schemas/BaseProblem'
    InvalidFields:
      type: array
      description: Invalid field details.
      items:
        type: object
        properties:
          field:
            type: string
            description: |-
              Name of the field.
              Dot notation is used for nested object field names.
          message:
            description: Message field.
            type: string
      example:
        - field: field1
          message: field1 is invalid
        - field: subObject.field2
          message: field2 is invalid
        - field: subObject.field2
          message: another error in the field2
    ValidationError:
      allOf:
        - title: Validation error
        - type: object
          properties:
            status:
              type: integer
              description: HTTP status code.
              minimum: 422
              maximum: 422
        - $ref: '#/components/schemas/BaseProblem'
        - type: object
          properties:
            invalidFields:
              $ref: '#/components/schemas/InvalidFields'
    TooManyRequests:
      type: object
      additionalProperties: true
      minProperties: 1
      description: RFC-7807 [problem details](https://tools.ietf.org/html/rfc7807) JSON object.
      properties:
        type:
          type: string
          description: |-
            Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference.
            It should provide human-readable documentation for the problem type.
            When this member is not present, its value is assumed to be "about:blank".
          format: uri
          example: about:blank
        title:
          type: string
          description: |-
            Short, human-readable summary of the problem type.
            Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.
          example: Rate Limit Exceeded
        status:
          type: integer
          description: HTTP status code.
          minimum: 429
          maximum: 429
        detail:
          type: string
          description: Human-readable explanation that is specific to this occurrence of the problem.
          example: A request cannot be executed because the user has sent too many requests within a certain period of time
        instance:
          type: string
          description: |-
            URI reference that identifies the specific occurrence of the problem.
            It may or may not yield further information if dereferenced.
    CouponRestrictionDiscountPerRedemption:
      type: object
      description: |-
        Restricts the number of times that the coupon can be applied by one
        redemption. For example, use this restriction to configure a coupon
        that can only be applied to the first subscription renewal of a
        particular product.
      required:
        - type
        - quantity
      properties:
        type:
          description: Type of coupon restriction.
          type: string
          enum:
            - discounts-per-redemption
        quantity:
          type: integer
          description: Permitted number of discounts per redemption.
    CouponRestrictionMaximumOrderAmount:
      type: object
      description: |-
        Specifies a maximum order amount for a coupon application.
        For example, if the restriction amount is $20, 
        the coupon is only applied to invoices with a total amount of $20 or less.
      required:
        - type
        - amount
        - currency
      properties:
        type:
          type: string
          description: Type of coupon restriction.
          enum:
            - maximum-order-amount
        amount:
          type: number
          format: double
          description: Maximum order amount that is allowed to apply the coupon.
        currency:
          $ref: '#/components/schemas/CurrencyCode'
    CouponRestrictionMinimumOrderAmount:
      type: object
      description: |-
        Specifies a minimum order amount for a coupon application. For
        example, if the restriction amount is $20, the coupon is only
        applied to invoices with a total amount of $20 or more.
      required:
        - type
        - amount
        - currency
      properties:
        type:
          type: string
          description: Type of coupon restriction.
          enum:
            - minimum-order-amount
        amount:
          type: number
          format: double
          description: Minimum order quantity that is required to apply the coupon.
        currency:
          $ref: '#/components/schemas/CurrencyCode'
    CouponRestrictionPaidByTime:
      type: object
      description: Specifies a date and time at which a coupon redemption expires if the invoice is not paid.
      required:
        - type
        - time
      properties:
        type:
          description: Type of coupon restriction.
          type: string
          enum:
            - paid-by-time
        time:
          type: string
          format: date-time
          description: |-
            Date and time when a coupon redemption is no longer valid, and the coupon is removed from unpaid invoices if applied.

            > **Note:** This date-time cannot be changed.
    CouponRestrictionRestrictToInvoices:
      type: object
      description: Restricts a coupon to specific invoices.
      required:
        - type
        - invoiceIds
      properties:
        type:
          type: string
          description: Type of coupon restriction.
          enum:
            - restrict-to-invoices
        invoiceIds:
          type: array
          description: Invoice IDs on which a coupon can be applied.
          items:
            type: string
    CouponRestrictionRestrictToPlans:
      type: object
      description: Restricts a coupon to specific pricing plans.
      required:
        - type
        - planIds
      properties:
        type:
          type: string
          description: Type of coupon restriction.
          enum:
            - restrict-to-plans
        planIds:
          type: array
          description: Plan IDs on which a coupon can be applied.
          items:
            type: string
        minimumQuantity:
          type: integer
          default: 1
          description: Minimum quantity that is required to apply the restriction and subsequent discount.
    CouponRestrictionRestrictToProducts:
      type: object
      description: Restricts a coupon to specific products.
      required:
        - type
        - productIds
      properties:
        type:
          type: string
          description: Type of coupon restriction.
          enum:
            - restrict-to-products
        productIds:
          type: array
          description: Product IDs on which a coupon can be applied.
          items:
            type: string
        minimumQuantity:
          type: integer
          default: 1
          description: Minimum quantity that is required to apply the restriction and subsequent discount.
    CouponRestrictionRestrictToSubscriptions:
      type: object
      description: Restricts a coupon to specific order subscriptions.
      required:
        - type
        - subscriptionIds
      properties:
        type:
          type: string
          description: Type of coupon restriction.
          enum:
            - restrict-to-subscriptions
        subscriptionIds:
          type: array
          description: Subscription IDs on which a coupon can be applied.
          items:
            type: string
    DiscountFixed:
      type: object
      description: Coupon fixed amount discount.
      required:
        - amount
        - currency
        - type
      properties:
        amount:
          description: Amount of discount.
          type: number
          format: double
          minimum: 0.01
        currency:
          $ref: '#/components/schemas/CurrencyCode'
        type:
          type: string
          enum:
            - fixed
          x-label: Type
          x-sortable: true
          x-basic: true
        context:
          $ref: '#/components/schemas/DiscountContext'
    DiscountPercent:
      type: object
      description: Coupon percent discount.
      required:
        - value
        - type
      properties:
        value:
          description: Percentage of discount.
          type: number
          format: double
          minimum: 0.01
          maximum: 100
        type:
          type: string
          enum:
            - percent
          x-label: Type
          x-sortable: true
          x-basic: true
        context:
          $ref: '#/components/schemas/DiscountContext'
    Discount:
      type: object
      description: Coupon discount.
      discriminator:
        propertyName: type
        mapping:
          fixed: '#/components/schemas/DiscountFixed'
          percent: '#/components/schemas/DiscountPercent'
      oneOf:
        - $ref: '#/components/schemas/DiscountFixed'
        - $ref: '#/components/schemas/DiscountPercent'
    CouponRestrictionRedemptionsPerCustomer:
      type: object
      description: |-
        Restricts the number of times that a coupon can be redeemed by one
        customer. For example, use this restriction to limit the number of
        redemptions to one per customer.
      required:
        - type
        - quantity
      properties:
        type:
          type: string
          description: Type of coupon restriction.
          enum:
            - redemptions-per-customer
        quantity:
          type: integer
          description: Permitted number of redemptions per customer.
    CouponRestrictionRestrictToBxgy:
      type: object
      description: |-
        Provides "buy X get Y" promotions.
        These promotions incentivize new customers to buy and also reward existing customers.
        Use this restriction type to add discounted plans to an invoice when a certain quantity of other plans are purchased.
        For example, if a customer buys two or more books, they get one free bookmark.
      required:
        - type
        - buy
        - get
      properties:
        type:
          type: string
          description: Type of coupon restriction.
          enum:
            - restrict-to-bxgy
        buy:
          type: array
          description: |-
            One or more plan and quantity definitions that must be purchased to receive all plans and quantities that are defined in the `get` instruction.
            All `planId` values in this array must be unique.
          minItems: 1
          items:
            type: object
            required:
              - planId
              - quantity
            properties:
              planId:
                type: string
                description: |-
                  Plan ID of the item being purchased.
                  This value must be unique within the `buy.items` array.
                maxLength: 50
                example: plan_0YV7DENSVGDBW9S71XZNNYYQ0X
              quantity:
                type: integer
                minimum: 1
                description: Total quantity of the associated plan ID that must be purchased for this restriction to apply.
        get:
          type: array
          description: |-
            One or more plan and quantity definitions that are added to a purchase if all definitions in the `buy` condition are met.
            All `planId` values in this array must be unique.
          minItems: 1
          items:
            type: object
            required:
              - planId
              - quantity
            properties:
              planId:
                type: string
                description: |-
                  Plan ID of the item that is to be received by the customer.
                  This value must be unique within the `get.items` array.
                maxLength: 50
                example: plan_0YV7DENSVGDBW9S71XZNNYYQ0X
              quantity:
                type: integer
                minimum: 1
                description: Total quantity of the associated plan ID that is to be received by the customer.
    CouponRestrictionRestrictToCountries:
      type: object
      description: Restricts a coupon for use in specific countries.
      required:
        - type
        - countries
      properties:
        type:
          type: string
          description: Type of coupon restriction.
          enum:
            - restrict-to-countries
        countries:
          type: array
          description: |-
            Countries where the coupon can be applied, in ISO Alpha-2 code format.
            For examples, see [ISO.org](https://www.iso.org/obp/ui/#search/code/).
          items:
            type: string
            pattern: ^[A-Z]{2}$
    CouponRestrictionRestrictToCustomerTags:
      type: object
      description: Restricts a coupon to customers with specific tags.
      required:
        - type
        - tags
        - requireAllTags
      properties:
        type:
          type: string
          description: Type of coupon restriction.
          enum:
            - restrict-to-customer-tags
        tags:
          type: array
          description: Customer tags on which a coupon can be applied.
          items:
            type: string
        requireAllTags:
          type: boolean
          description: |-
            Specifies if the customer must have all listed tags,
            or at least one of the listed tags, to redeem a coupon.
          enum:
            - true
            - false
          x-enumDescriptions:
            'true': Customer must have all listed tags to redeem a coupon.
            'false': Customer must have at least one of the listed tags to redeem a coupon.
    CouponRestrictionRestrictToCustomers:
      type: object
      description: Restricts a coupon to specific customers.
      required:
        - type
        - customerIds
      properties:
        type:
          type: string
          description: Type of coupon restriction.
          enum:
            - restrict-to-customers
        customerIds:
          type: array
          description: Customer IDs on which a coupon can be applied.
          items:
            type: string
    CouponRestrictionExclusiveApplication:
      type: object
      description: |-
        Restricts a coupon so that it cannot be used in combination with other coupons.
        If more than one coupon is active, a coupon with this restriction is only applied if it provides a larger discount than the other coupons combined.
        If a coupon with this restriction is applied, all other coupons are removed.
      required:
        - type
      properties:
        type:
          type: string
          description: Type of coupon restriction.
          enum:
            - restrict-to-exclusive-application
    CouponRestrictionTotalRedemptions:
      type: object
      description: Restricts the number of times a coupon can be redeemed by different customers.
      required:
        - type
        - quantity
      properties:
        type:
          type: string
          description: Type of coupon restriction.
          enum:
            - total-redemptions
        quantity:
          type: integer
          description: Permitted total number of redemptions.
    CouponRestriction:
      description: Coupon restrictions.
      type: object
      discriminator:
        propertyName: type
        mapping:
          discounts-per-redemption: '#/components/schemas/CouponRestrictionDiscountPerRedemption'
          maximum-order-amount: '#/components/schemas/CouponRestrictionMaximumOrderAmount'
          minimum-order-amount: '#/components/schemas/CouponRestrictionMinimumOrderAmount'
          paid-by-time: '#/components/schemas/CouponRestrictionPaidByTime'
          redemptions-per-customer: '#/components/schemas/CouponRestrictionRedemptionsPerCustomer'
          restrict-to-bxgy: '#/components/schemas/CouponRestrictionRestrictToBxgy'
          restrict-to-countries: '#/components/schemas/CouponRestrictionRestrictToCountries'
          restrict-to-customer-tags: '#/components/schemas/CouponRestrictionRestrictToCustomerTags'
          restrict-to-customers: '#/components/schemas/CouponRestrictionRestrictToCustomers'
          restrict-to-exclusive-application: '#/components/schemas/CouponRestrictionExclusiveApplication'
          restrict-to-invoices: '#/components/schemas/CouponRestrictionRestrictToInvoices'
          restrict-to-plans: '#/components/schemas/CouponRestrictionRestrictToPlans'
          restrict-to-products: '#/components/schemas/CouponRestrictionRestrictToProducts'
          restrict-to-subscriptions: '#/components/schemas/CouponRestrictionRestrictToSubscriptions'
          total-redemptions: '#/components/schemas/CouponRestrictionTotalRedemptions'
      oneOf:
        - $ref: '#/components/schemas/CouponRestrictionDiscountPerRedemption'
        - $ref: '#/components/schemas/CouponRestrictionExclusiveApplication'
        - $ref: '#/components/schemas/CouponRestrictionMaximumOrderAmount'
        - $ref: '#/components/schemas/CouponRestrictionMinimumOrderAmount'
        - $ref: '#/components/schemas/CouponRestrictionPaidByTime'
        - $ref: '#/components/schemas/CouponRestrictionRedemptionsPerCustomer'
        - $ref: '#/components/schemas/CouponRestrictionRestrictToBxgy'
        - $ref: '#/components/schemas/CouponRestrictionRestrictToCountries'
        - $ref: '#/components/schemas/CouponRestrictionRestrictToCustomerTags'
        - $ref: '#/components/schemas/CouponRestrictionRestrictToCustomers'
        - $ref: '#/components/schemas/CouponRestrictionRestrictToInvoices'
        - $ref: '#/components/schemas/CouponRestrictionRestrictToPlans'
        - $ref: '#/components/schemas/CouponRestrictionRestrictToProducts'
        - $ref: '#/components/schemas/CouponRestrictionRestrictToSubscriptions'
        - $ref: '#/components/schemas/CouponRestrictionTotalRedemptions'
    Coupon:
      type: object
      description: Coupons and discounts.
      required:
        - discount
        - issuedTime
      properties:
        id:
          type: string
          description: |-
            ID of the coupon.
            This value is also known as the coupon redemption code.
          readOnly: true
          maxLength: 50
          example: cpn_0YVCNKF81GD778N4YNVGDJK558
        discount:
          $ref: '#/components/schemas/Discount'
        restrictions:
          description: |-
            Coupon restrictions.
            All `type` values in this array must be unique.
          type: array
          items:
            $ref: '#/components/schemas/CouponRestriction'
        redemptionsCount:
          type: integer
          description: Total number of times that a coupon is redeemed.
          minimum: 0
          readOnly: true
        status:
          type: string
          description: Specifies the current status of the coupon.
          readOnly: true
          enum:
            - draft
            - issued
            - expired
        description:
          type: string
          x-basic: true
          description: |-
            Description of the coupon.
            Use this field to provide a description for the invoice discount item.

            If this field is empty,
            the invoice discount item description uses the related coupon ID,
            in the following format: `Coupon "COUPON-ID"`.
        issuedTime:
          description: |-
            Date and time when the coupon is issued.
            This value may also be described as start time of the coupon.
          type: string
          x-label: Valid from
          x-sortable: true
          x-basic: true
          format: date-time
        expiredTime:
          description: Date and time when the coupon expires.
          type:
            - string
            - 'null'
          x-label: Valid until
          x-sortable: true
          x-basic: true
          format: date-time
        revision:
          description: |-
            Number of times the coupon data has been modified.

            Use the revision number when analyzing webhook data to
            determine if a change should take precedence over the current
            representation.
          type: integer
          readOnly: true
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        _links:
          $ref: '#/components/schemas/SelfLink'
  responses:
    Unauthorized:
      description: |-
        Unauthorized access.
        Invalid credentials used.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Unauthorized'
    Forbidden:
      description: |-
        Access forbidden.
        If the organization requires multi-factor authentication (MFA) and the session has not passed MFA, `error` is `mfa_required`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Forbidden'
    ValidationError:
      description: Invalid data sent.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ValidationError'
    TooManyRequests:
      description: Request rate limit exceeded.
      headers:
        Rate-Limit-Limit:
          $ref: '#/components/headers/Rate-Limit-Limit'
        Rate-Limit-Remaining:
          description: |-
            Number of requests still available for this rate limit.
            For more information, see [Rate limits](#section/Rate-limits).
          schema:
            type: integer
          example: 0
        Rate-Limit-Retry-After:
          $ref: '#/components/headers/Rate-Limit-Retry-After'
        Retry-After:
          description: Number of seconds to wait before retrying the request.
          schema:
            type: integer
          example: 1
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/TooManyRequests'
  requestBodies:
    Coupon:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Coupon'
      description: Coupon resource.
      required: true
```
