> ## 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.

# Recalculate invoices

> Enqueues the recalculation of every recalculable invoice whose invoice date falls inside the period, which cannot span more than one month. A period that ends before it starts, or spans more than one month, is rejected with `invalid_period_range`. Canceled, locked and one-off invoices are left untouched, and invoices sharing an allocation group are enqueued once. Use `GET /invoices` with the same `invoiceDate` window to preview the selection.



## OpenAPI

````yaml /api-reference/openapi.yaml post /v1/invoices/recalculate
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/recalculate:
    post:
      tags:
        - Invoices
      summary: Recalculate invoices
      description: >-
        Enqueues the recalculation of every recalculable invoice whose invoice
        date falls inside the period, which cannot span more than one month. A
        period that ends before it starts, or spans more than one month, is
        rejected with `invalid_period_range`. Canceled, locked and one-off
        invoices are left untouched, and invoices sharing an allocation group
        are enqueued once. Use `GET /invoices` with the same `invoiceDate`
        window to preview the selection.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                invoiceDate:
                  type: object
                  description: >-
                    The invoice date period to recalculate. The period cannot
                    span more than 1 month.
                  properties:
                    gte:
                      type: string
                      format: date
                      description: >-
                        Only recalculate invoices whose invoice date is on or
                        after this date.
                    lte:
                      type: string
                      format: date
                      description: >-
                        Only recalculate invoices whose invoice date is on or
                        before this date.
                  required:
                    - gte
                    - lte
                  additionalProperties: false
              required:
                - invoiceDate
              additionalProperties: false
        required: true
      responses:
        '202':
          description: The recalculation has been enqueued.
          content:
            application/json:
              schema:
                type: object
                properties:
                  total:
                    type: number
                    description: How many invoices were enqueued for recalculation.
                  capped:
                    type: boolean
                    description: >-
                      Whether the period matched more than 10000 recalculable
                      invoices. When true, only the first 10000 were enqueued
                      and the remaining ones need a narrower period.
                required:
                  - total
                  - capped
                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
components:
  securitySchemes:
    ApiKey:
      type: apiKey
      description: API Key Authentication.
      name: X-API-KEY
      in: header

````