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

# Create a coupon



## OpenAPI

````yaml https://api.meteroid.com/api-docs/openapi.json post /api/v1/coupons
openapi: 3.1.0
info:
  title: meteroid
  description: ''
  license:
    name: LicenseRef-Meteroid-EE
    identifier: LicenseRef-Meteroid-EE
  version: 0.1.0
servers: []
security: []
tags:
  - name: Add-ons
  - name: Batch Jobs
  - name: Budgets
    description: >-
      Beta: may change before general availability. Spending limits on a
      customer's usage, or one subscription's, per currency, with alerts at
      percentages of the amount.
    x-beta: true
  - name: Checkout Sessions
  - name: Checks
    description: >-
      Beta: may change before general availability. Whether a customer may
      consume more of a feature right now.
    x-beta: true
  - name: Connect
    description: Manage connected accounts (Express & Standard)
  - name: Coupons
  - name: Credit Notes
  - name: Credit units
    description: >-
      Custom denominations, such as "credits", that usage can be priced in and
      credit granted or sold in, instead of money.
  - name: Credits
    description: >-
      Prepaid credit: a customer's wallets, credit grants, ledger and top-ups.
      Promotional credit applies before tax like a discount; paid credit applies
      after tax like a payment.
  - name: Custom Properties
  - name: Customers
  - name: Entitlements
  - name: Events
  - name: Features
  - name: Invoices
  - name: Licenses
    description: >-
      Licenses for your customers' self-hosted installations: signed tokens
      carrying their plan's entitlements, activated and refreshed by the
      installation over the public licensing endpoints.
  - name: Metrics
  - name: OAuth
    description: OAuth 2.0 token endpoints (public, client-credentials auth)
  - name: OAuth Apps
    description: Manage OAuth applications for Connect integrations
  - name: Plans
  - name: Product Families
  - name: Products
  - name: Subscriptions
  - name: Usage
  - name: Usage costs
    description: >-
      Beta: may change before general availability. A customer's or a
      subscription's usage events and usage over time, with what they cost.
    x-beta: true
  - name: Webhook Endpoints
    description: Manage outbound webhook endpoints and inspect their deliveries
paths:
  /api/v1/coupons:
    post:
      tags:
        - Coupons
      summary: Create a coupon
      operationId: create_coupon
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCouponRequest'
        required: true
      responses:
        '201':
          description: Coupon created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Coupon'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestErrorResponse'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestErrorResponse'
      security:
        - bearer_auth: []
components:
  schemas:
    CreateCouponRequest:
      type: object
      required:
        - code
        - discount
      properties:
        code:
          type: string
          description: >-
            1 to 64 ASCII letters, digits, hyphens or underscores. A
            promotional-credit (`CREDIT`) code

            is stored upper-case. Codes are matched as described on
            `Coupon.code`.
        description:
          type:
            - string
            - 'null'
        discount:
          $ref: '#/components/schemas/CouponDiscount'
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
        plan_ids:
          type: array
          items:
            $ref: '#/components/schemas/PlanId'
        recurring_value:
          type:
            - integer
            - 'null'
          format: int32
        redemption_limit:
          type:
            - integer
            - 'null'
          format: int32
        reusable:
          type: boolean
          description: >-
            Whether one customer may redeem the coupon more than once. Must be
            false for a

            promotional-credit (`CREDIT`) coupon.
    Coupon:
      type: object
      required:
        - id
        - code
        - discount
        - reusable
        - disabled
        - created_at
        - redemption_count
        - plan_ids
      properties:
        archived_at:
          type:
            - string
            - 'null'
          format: date-time
        code:
          type: string
          description: >-
            A promotional-credit (`CREDIT`) code is stored upper-case; other
            codes as written. A code

            is redeemed by the coupon with exactly that code, else by the only
            live coupon equal to it

            ignoring the case of ASCII letters; several such coupons and no
            exact match make it

            ambiguous.
        created_at:
          type: string
          format: date-time
        description:
          type:
            - string
            - 'null'
        disabled:
          type: boolean
        discount:
          $ref: '#/components/schemas/CouponDiscount'
        expires_at:
          type:
            - string
            - 'null'
          format: date-time
        id:
          $ref: '#/components/schemas/CouponId'
        plan_ids:
          type: array
          items:
            $ref: '#/components/schemas/PlanId'
        recurring_value:
          type:
            - integer
            - 'null'
          format: int32
        redemption_count:
          type: integer
          format: int32
        redemption_limit:
          type:
            - integer
            - 'null'
          format: int32
        reusable:
          type: boolean
    RestErrorResponse:
      type: object
      required:
        - code
        - message
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
    CouponDiscount:
      oneOf:
        - $ref: '#/components/schemas/PercentageDiscount'
        - $ref: '#/components/schemas/FixedDiscount'
        - $ref: '#/components/schemas/CreditDiscount'
      discriminator:
        propertyName: type
        mapping:
          CREDIT: '#/components/schemas/CreditDiscount'
          FIXED: '#/components/schemas/FixedDiscount'
          PERCENTAGE: '#/components/schemas/PercentageDiscount'
    PlanId:
      type: string
      format: MeteroidId
      examples:
        - plan_7n42DGM5Tflk9n8mt7Fhc7
    CouponId:
      type: string
      format: MeteroidId
      examples:
        - cou_7n42DGM5Tflk9n8mt7Fhc7
    ErrorCode:
      type: string
      enum:
        - BAD_REQUEST
        - NOT_FOUND
        - CONFLICT
        - FORBIDDEN
        - UNAUTHORIZED
        - TOKEN_EXPIRED
        - TOO_MANY_REQUESTS
        - INTERNAL_SERVER_ERROR
    PercentageDiscount:
      type: object
      required:
        - percentage
        - type
      properties:
        percentage:
          type: string
        type:
          type: string
          enum:
            - PERCENTAGE
    FixedDiscount:
      type: object
      required:
        - currency
        - amount
        - type
      properties:
        amount:
          type: string
        currency:
          type: string
        type:
          type: string
          enum:
            - FIXED
    CreditDiscount:
      type: object
      description: >-
        Promotional credit added to the customer's credit balance when the
        subscription the coupon is

        redeemed on starts. It never discounts an invoice and applies before
        tax. A customer redeems

        it at most once, so the coupon cannot be `reusable`. Its code is
        case-insensitive: it is stored

        upper-case and redeemed whatever the case.
      required:
        - currency
        - amount
        - type
      properties:
        amount:
          type: string
          description: Credit added per redemption, in major units (e.g. "25.00").
        currency:
          type: string
          description: >-
            ISO 4217 code; it must match the currency of the subscription the
            coupon is redeemed on.
        expires_in_days:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            Days the credit stays spendable after redemption, 1 to 3660. Absent:
            it never expires.
          minimum: 0
        scope:
          $ref: '#/components/schemas/CouponCreditScope'
          description: >-
            CUSTOMER (default): the credit pays any of the customer's
            subscriptions. SUBSCRIPTION: the

            credit pays only the subscription the code is redeemed on, and ends
            with it.
        type:
          type: string
          enum:
            - CREDIT
    CouponCreditScope:
      type: string
      description: Which subscriptions a promotional credit coupon's credit pays.
      enum:
        - CUSTOMER
        - SUBSCRIPTION
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.