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

# Create Discount



## OpenAPI

````yaml https://app.flowglad.com/api/openapi post /api/v1/discounts
openapi: 3.1.0
info:
  title: Flowglad API
  version: 0.0.1
servers:
  - url: https://app.flowglad.com
security: []
externalDocs:
  url: https://docs.flowglad.com
paths:
  /api/v1/discounts:
    post:
      tags:
        - Discounts
      summary: Create Discount
      operationId: discounts-create
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                discount:
                  $ref: '#/components/schemas/DiscountInsert'
                  description: >-
                    A discount record, which describes a discount that can be
                    applied to purchases or subscriptions. Discounts can be
                    one-time, have a fixed number of payments, or be applied
                    indefinitely.
              required:
                - discount
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  discount:
                    $ref: '#/components/schemas/DiscountRecord'
                    description: >-
                      A discount record, which describes a discount that can be
                      applied to purchases or subscriptions. Discounts can be
                      one-time, have a fixed number of payments, or be applied
                      indefinitely.
                required:
                  - discount
                additionalProperties: false
        '400':
          description: Invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.BAD_REQUEST'
        '401':
          description: Authorization not provided
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.UNAUTHORIZED'
        '403':
          description: Insufficient access
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.FORBIDDEN'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.INTERNAL_SERVER_ERROR'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    DiscountInsert:
      anyOf:
        - $ref: '#/components/schemas/DefaultDiscountClientInsertSchema'
        - $ref: '#/components/schemas/NumberOfPaymentsDiscountClientInsertSchema'
        - $ref: '#/components/schemas/ForeverDiscountClientInsertSchema'
    DiscountRecord:
      anyOf:
        - $ref: '#/components/schemas/ForeverDiscountClientSelectSchema'
        - $ref: '#/components/schemas/NumberOfPaymentsDiscountClientSelectSchema'
        - $ref: '#/components/schemas/DefaultDiscountClientSelectSchema'
    error.BAD_REQUEST:
      title: Invalid input data error (400)
      description: The error information
      example:
        code: BAD_REQUEST
        message: Invalid input data
        issues: []
      type: object
      properties:
        message:
          description: The error message
          example: Invalid input data
          type: string
        code:
          description: The error code
          example: BAD_REQUEST
          type: string
        issues:
          description: An array of issues that were responsible for the error
          example: []
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
            additionalProperties: false
      required:
        - message
        - code
      additionalProperties: false
    error.UNAUTHORIZED:
      title: Authorization not provided error (401)
      description: The error information
      example:
        code: UNAUTHORIZED
        message: Authorization not provided
        issues: []
      type: object
      properties:
        message:
          description: The error message
          example: Authorization not provided
          type: string
        code:
          description: The error code
          example: UNAUTHORIZED
          type: string
        issues:
          description: An array of issues that were responsible for the error
          example: []
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
            additionalProperties: false
      required:
        - message
        - code
      additionalProperties: false
    error.FORBIDDEN:
      title: Insufficient access error (403)
      description: The error information
      example:
        code: FORBIDDEN
        message: Insufficient access
        issues: []
      type: object
      properties:
        message:
          description: The error message
          example: Insufficient access
          type: string
        code:
          description: The error code
          example: FORBIDDEN
          type: string
        issues:
          description: An array of issues that were responsible for the error
          example: []
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
            additionalProperties: false
      required:
        - message
        - code
      additionalProperties: false
    error.INTERNAL_SERVER_ERROR:
      title: Internal server error error (500)
      description: The error information
      example:
        code: INTERNAL_SERVER_ERROR
        message: Internal server error
        issues: []
      type: object
      properties:
        message:
          description: The error message
          example: Internal server error
          type: string
        code:
          description: The error code
          example: INTERNAL_SERVER_ERROR
          type: string
        issues:
          description: An array of issues that were responsible for the error
          example: []
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
            additionalProperties: false
      required:
        - message
        - code
      additionalProperties: false
    DefaultDiscountClientInsertSchema:
      type: object
      properties:
        name:
          type: string
        code:
          description: The discount code, must be unique and between 3 and 20 characters.
          type: string
        amount:
          description: A positive integer
          type: integer
          exclusiveMinimum: 0
          maximum: 9007199254740991
        amountType:
          type: string
          enum:
            - percent
            - fixed
        active:
          type: boolean
        duration:
          type: string
          const: once
        numberOfPayments:
          type: 'null'
      required:
        - name
        - code
        - amount
        - amountType
        - duration
    NumberOfPaymentsDiscountClientInsertSchema:
      type: object
      properties:
        name:
          type: string
        code:
          description: The discount code, must be unique and between 3 and 20 characters.
          type: string
        amount:
          description: A positive integer
          type: integer
          exclusiveMinimum: 0
          maximum: 9007199254740991
        amountType:
          type: string
          enum:
            - percent
            - fixed
        active:
          type: boolean
        duration:
          type: string
          const: number_of_payments
        numberOfPayments:
          description: A positive integer
          type: integer
          exclusiveMinimum: 0
          maximum: 9007199254740991
      required:
        - name
        - code
        - amount
        - amountType
        - duration
        - numberOfPayments
    ForeverDiscountClientInsertSchema:
      type: object
      properties:
        name:
          type: string
        code:
          description: The discount code, must be unique and between 3 and 20 characters.
          type: string
        amount:
          description: A positive integer
          type: integer
          exclusiveMinimum: 0
          maximum: 9007199254740991
        amountType:
          type: string
          enum:
            - percent
            - fixed
        active:
          type: boolean
        duration:
          type: string
          const: forever
        numberOfPayments:
          type: 'null'
      required:
        - name
        - code
        - amount
        - amountType
        - duration
    ForeverDiscountClientSelectSchema:
      type: object
      properties:
        id:
          type: string
        createdAt:
          description: Epoch milliseconds.
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        updatedAt:
          description: Epoch milliseconds.
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        livemode:
          type: boolean
        organizationId:
          type: string
        pricingModelId:
          type: string
        name:
          type: string
        code:
          description: The discount code, must be unique and between 3 and 20 characters.
          type: string
          minLength: 3
          maxLength: 20
        amount:
          description: A positive integer
          type: integer
          exclusiveMinimum: 0
          maximum: 9007199254740991
        amountType:
          type: string
          enum:
            - percent
            - fixed
        active:
          type: boolean
        duration:
          type: string
          const: forever
        numberOfPayments:
          type: 'null'
      required:
        - id
        - createdAt
        - updatedAt
        - livemode
        - organizationId
        - pricingModelId
        - name
        - code
        - amount
        - amountType
        - active
        - duration
      additionalProperties: false
    NumberOfPaymentsDiscountClientSelectSchema:
      type: object
      properties:
        id:
          type: string
        createdAt:
          description: Epoch milliseconds.
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        updatedAt:
          description: Epoch milliseconds.
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        livemode:
          type: boolean
        organizationId:
          type: string
        pricingModelId:
          type: string
        name:
          type: string
        code:
          description: The discount code, must be unique and between 3 and 20 characters.
          type: string
          minLength: 3
          maxLength: 20
        amount:
          description: A positive integer
          type: integer
          exclusiveMinimum: 0
          maximum: 9007199254740991
        amountType:
          type: string
          enum:
            - percent
            - fixed
        active:
          type: boolean
        duration:
          type: string
          const: number_of_payments
        numberOfPayments:
          description: A positive integer
          type: integer
          exclusiveMinimum: 0
          maximum: 9007199254740991
      required:
        - id
        - createdAt
        - updatedAt
        - livemode
        - organizationId
        - pricingModelId
        - name
        - code
        - amount
        - amountType
        - active
        - duration
        - numberOfPayments
      additionalProperties: false
    DefaultDiscountClientSelectSchema:
      type: object
      properties:
        id:
          type: string
        createdAt:
          description: Epoch milliseconds.
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        updatedAt:
          description: Epoch milliseconds.
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        livemode:
          type: boolean
        organizationId:
          type: string
        pricingModelId:
          type: string
        name:
          type: string
        code:
          description: The discount code, must be unique and between 3 and 20 characters.
          type: string
          minLength: 3
          maxLength: 20
        amount:
          description: A positive integer
          type: integer
          exclusiveMinimum: 0
          maximum: 9007199254740991
        amountType:
          type: string
          enum:
            - percent
            - fixed
        active:
          type: boolean
        duration:
          type: string
          const: once
        numberOfPayments:
          type: 'null'
      required:
        - id
        - createdAt
        - updatedAt
        - livemode
        - organizationId
        - pricingModelId
        - name
        - code
        - amount
        - amountType
        - active
        - duration
      additionalProperties: false
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization

````