> ## 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 line item

> Creates a line item on a one-off invoice, optionally with sub-line items. When sub-line items are provided, their amounts must sum to the line item amount.



## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/invoices/{invoiceId}/line-items
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}/line-items:
    post:
      tags:
        - Invoices
      summary: Create invoice line item
      description: >-
        Creates a line item on a one-off invoice, optionally with sub-line
        items. When sub-line items are provided, their amounts must sum to the
        line item amount.
      parameters:
        - schema:
            type: string
            format: uuid
          in: path
          name: invoiceId
          required: true
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                idempotencyKey:
                  type: string
                  minLength: 1
                  pattern: ^[a-zA-Z0-9_-]+$
                  description: >-
                    A unique idempotency key for this line item, scoped to the
                    invoice.
                productId:
                  type: string
                  format: uuid
                itemId:
                  type: string
                  format: uuid
                name:
                  type: string
                  nullable: true
                  description: >-
                    Optional line item name; defaults to the item name (or
                    product name as fallback) when null.
                startDate:
                  type: string
                  format: date
                endDate:
                  type: string
                  format: date
                lineItemGroupId:
                  type: string
                  format: uuid
                  nullable: true
                  description: >-
                    Optional line item group to attach this line item to. The
                    group must belong to the same invoice.
                amount:
                  type: number
                subLineItems:
                  type: array
                  description: >-
                    Optional breakdown of the line item amount into sub-line
                    items. When provided, amounts must sum to amount.
                  items:
                    type: object
                    properties:
                      usage:
                        type: number
                      amount:
                        type: number
                    required:
                      - usage
                      - amount
                    additionalProperties: false
                  default: []
              required:
                - idempotencyKey
                - productId
                - itemId
                - startDate
                - endDate
                - amount
              additionalProperties: false
        required: true
        description: >-
          Schema for creating a one-off line item on an existing one-off
          invoice. When subLineItems is provided, the sum of subLineItems.amount
          must equal amount.
      responses:
        '200':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                  idempotencyKey:
                    type: string
                  customerId:
                    type: string
                    format: uuid
                  productId:
                    type: string
                    format: uuid
                  itemId:
                    type: string
                    nullable: true
                    format: uuid
                  resourceId:
                    type: string
                    nullable: true
                    format: uuid
                  lineItemGroupId:
                    type: string
                    nullable: true
                    format: uuid
                  name:
                    type: string
                  scope:
                    type: string
                    enum:
                      - credit_purchase
                      - contract_minimum_amount
                      - plan_minimum_amount
                      - plan_fixed_amount
                      - metric
                      - additional_charge
                      - one_off
                      - tax_gross_up
                  startDate:
                    type: string
                    format: date
                  endDate:
                    type: string
                    format: date
                  totalUsage:
                    type: number
                    nullable: true
                  usageFormat:
                    type: string
                    enum:
                      - unit
                      - currency
                      - null
                    nullable: true
                  subtotalAmount:
                    type: number
                  adjustmentAmount:
                    type: number
                  totalAmount:
                    type: number
                  discountAmount:
                    type: number
                  metadata:
                    anyOf:
                      - type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - metric
                          billingModel:
                            type: string
                            enum:
                              - in_full
                              - proration
                          priceTierDivision:
                            type: string
                            enum:
                              - unique_tier
                              - progressive
                        required:
                          - type
                          - billingModel
                          - priceTierDivision
                      - type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - contract_minimum_amount
                          minimumAmount:
                            type: number
                          minimumAmountApplied:
                            type: number
                        required:
                          - type
                          - minimumAmount
                          - minimumAmountApplied
                      - type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - plan_minimum_amount
                          minimumAmount:
                            type: number
                          minimumAmountApplied:
                            type: number
                        required:
                          - type
                          - minimumAmount
                          - minimumAmountApplied
                      - type: 'null'
                  subLineItems:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          format: uuid
                        type:
                          type: string
                          enum:
                            - fixed_price
                            - minimum_amount
                            - price_tier_flat
                            - price_tier_unit
                            - price_tier_package
                            - price_tier_basis_points
                            - proration
                            - unit_price
                        name:
                          type: string
                        description:
                          type: string
                          nullable: true
                        usage:
                          type: number
                          nullable: true
                        amount:
                          type: number
                        metadata:
                          anyOf:
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - fixed_price
                                fixedPrice:
                                  type: number
                              required:
                                - type
                                - fixedPrice
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - minimum_amount
                                minimumAmount:
                                  type: number
                                minimumAmountApplied:
                                  type: number
                              required:
                                - type
                                - minimumAmount
                                - minimumAmountApplied
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - price_tier_flat
                                from:
                                  type: number
                                to:
                                  type: number
                                  nullable: true
                                fixedPrice:
                                  type: string
                              required:
                                - type
                                - from
                                - to
                                - fixedPrice
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - price_tier_unit
                                from:
                                  type: number
                                to:
                                  type: number
                                  nullable: true
                                price:
                                  type: string
                                fixedPrice:
                                  type: string
                                  nullable: true
                              required:
                                - type
                                - from
                                - to
                                - price
                                - fixedPrice
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - price_tier_package
                                from:
                                  type: number
                                to:
                                  type: number
                                  nullable: true
                                packageSize:
                                  type: number
                                price:
                                  type: string
                                fixedPrice:
                                  type: string
                                  nullable: true
                              required:
                                - type
                                - from
                                - to
                                - packageSize
                                - price
                                - fixedPrice
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - price_tier_basis_points
                                from:
                                  type: number
                                to:
                                  type: number
                                  nullable: true
                                basisPoints:
                                  type: number
                                fixedPrice:
                                  type: string
                                  nullable: true
                              required:
                                - type
                                - from
                                - to
                                - basisPoints
                                - fixedPrice
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - proration
                                intervalSize:
                                  type: number
                                amount:
                                  type: string
                                usage:
                                  type: number
                                intervalStart:
                                  type: string
                                  format: date
                                intervalEnd:
                                  type: string
                                  format: date
                              required:
                                - type
                                - intervalSize
                                - amount
                                - usage
                                - intervalStart
                                - intervalEnd
                            - type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - unit_price
                                price:
                                  type: string
                              required:
                                - type
                                - price
                      required:
                        - id
                        - type
                        - name
                        - description
                        - usage
                        - amount
                        - metadata
                      additionalProperties: false
                  adjustments:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          format: uuid
                        name:
                          type: string
                        type:
                          type: string
                          enum:
                            - monetary_discount
                            - allocation_offset
                        amount:
                          type: number
                      required:
                        - id
                        - name
                        - type
                        - amount
                      additionalProperties: false
                required:
                  - id
                  - idempotencyKey
                  - customerId
                  - productId
                  - resourceId
                  - lineItemGroupId
                  - name
                  - scope
                  - startDate
                  - endDate
                  - totalUsage
                  - usageFormat
                  - subtotalAmount
                  - adjustmentAmount
                  - totalAmount
                  - discountAmount
                  - metadata
                  - subLineItems
                  - adjustments
                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
        '409':
          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
components:
  securitySchemes:
    ApiKey:
      type: apiKey
      description: API Key Authentication.
      name: X-API-KEY
      in: header

````