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

# Create invoice discount

> Creates a manual discount on an invoice. The discount can target the whole invoice, a line item group, or a single line item (via targetIdempotencyKey).



## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/invoices/{invoiceId}/discounts
openapi: 3.1.0
info:
  title: API Reference
  version: '1.0'
  description: Aira API Reference
  x-logo:
    url: https://static.useaira.com/images/airalogo.svg
    backgroundColor: '#FFFFFF'
    altText: Aira Logo
servers:
  - url: https://api.useaira.com
    description: API base URL
security:
  - ApiKey: []
paths:
  /v1/invoices/{invoiceId}/discounts:
    post:
      tags:
        - Invoices
      summary: Create invoice discount
      description: >-
        Creates a manual discount on an invoice. The discount can target the
        whole invoice, a line item group, or a single line item (via
        targetIdempotencyKey).
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
          description: The unique identifier of the invoice the discount belongs to.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                target:
                  type: string
                  enum:
                    - invoice
                    - line_item_group
                    - line_item
                  description: >-
                    What the discount applies to: the whole invoice, one line
                    item group, or one line item.
                targetIdempotencyKey:
                  type: string
                  description: >-
                    The idempotency key of the targeted invoice, line item
                    group, or line item, matching the target field.
                method:
                  type: string
                  enum:
                    - fixed
                    - percentage
                  description: >-
                    How amount is interpreted: fixed subtracts a monetary
                    amount; percentage subtracts a percentage of the targeted
                    amount.
                description:
                  type: string
                  minLength: 1
                  description: Display text of the discount as it appears on the invoice.
                amount:
                  type: number
                  multipleOf: 1
                  minimum: 1
                  description: >-
                    Value of the discount, as a positive integer: whole cents
                    when method is fixed; basis points when method is percentage
                    (1 basis point = 0.01%; maximum 10000 = 100%).
              required:
                - target
                - targetIdempotencyKey
                - method
                - description
                - amount
              additionalProperties: false
        required: true
        description: >-
          Schema representing a discount on an invoice, on one of its line item
          groups, or on one of its line items. Only active discounts (see
          isActive) affect the invoice totals.
      responses:
        '201':
          description: >-
            Schema representing a discount on an invoice, on one of its line
            item groups, or on one of its line items. Only active discounts (see
            isActive) affect the invoice totals.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: The unique identifier of the discount in our system.
                  target:
                    type: string
                    enum:
                      - invoice
                      - line_item_group
                      - line_item
                    description: >-
                      What the discount applies to: the whole invoice, one line
                      item group, or one line item.
                  targetIdempotencyKey:
                    type: string
                    description: >-
                      The idempotency key of the targeted invoice, line item
                      group, or line item, matching the target field.
                  method:
                    type: string
                    enum:
                      - fixed
                      - percentage
                    description: >-
                      How amount is interpreted: fixed subtracts a monetary
                      amount; percentage subtracts a percentage of the targeted
                      amount.
                  reason:
                    type: string
                    enum:
                      - manual_discount
                      - contract_proration
                      - contract_recurring
                      - plan_instance_proration
                    description: >-
                      Why the discount exists: manual_discount (created by a
                      user or through the API), contract_proration or
                      plan_instance_proration (generated to prorate a partial
                      period), or contract_recurring (generated from a recurring
                      discount configured on the contract).
                  description:
                    type: string
                    minLength: 1
                    description: Display text of the discount as it appears on the invoice.
                  amount:
                    type: number
                    multipleOf: 1
                    minimum: 1
                    description: >-
                      Value of the discount, as a positive integer: whole cents
                      when method is fixed; basis points when method is
                      percentage (1 basis point = 0.01%; maximum 10000 = 100%).
                  isActive:
                    type: boolean
                    description: >-
                      Whether the discount is currently applied to the invoice
                      totals. Inactive discounts are kept for history but have
                      no effect.
                required:
                  - id
                  - target
                  - targetIdempotencyKey
                  - method
                  - reason
                  - description
                  - amount
                  - isActive
                additionalProperties: false
        '400':
          description: Error object returned to the client.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: A human-readable description of the error
                  code:
                    type: string
                    description: A unique identifier for the type of error
                  details:
                    oneOf:
                      - type: object
                        additionalProperties: true
                      - type: array
                    description: >-
                      Additional context about the error, such as invalid fields
                      or constraints. Each endpoint may include specific error
                      details in their documentation
                  causations:
                    type: array
                    description: >-
                      Optional array of error objects following the same
                      structure as the parent error. Only present when there's a
                      meaningful chain of related errors to expose
                    items:
                      type: object
                      properties:
                        message:
                          type: string
                          description: >-
                            A human-readable description of the underlying error
                            cause
                        code:
                          type: string
                          description: A unique identifier for the type of underlying error
                        details:
                          type: object
                          additionalProperties: true
                          description: Additional context about the underlying error
                      required:
                        - message
                        - code
                      additionalProperties: false
                required:
                  - code
                  - message
                additionalProperties: false
        '404':
          description: Error object returned to the client when a resource is not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: A human-readable description of the error
components:
  securitySchemes:
    ApiKey:
      type: apiKey
      description: API Key Authentication.
      name: X-API-KEY
      in: header

````