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

# Generate Order Invoice

> Trigger generation of an order's invoice.

**Scopes**: `orders:read`



## OpenAPI

````yaml /openapi.json post /v1/orders/{id}/invoice
openapi: 3.1.0
info:
  title: Polar API
  summary: Polar HTTP and Webhooks API
  description: Read the docs at https://polar.sh/docs/api-reference
  version: 2026-04
servers:
  - url: https://api.polar.sh
    description: Production environment
    x-speakeasy-server-id: production
    x-polar-environment: production
  - url: https://sandbox-api.polar.sh
    description: Sandbox environment
    x-speakeasy-server-id: sandbox
    x-polar-environment: sandbox
security: []
tags:
  - name: public
    description: >-
      Endpoints shown and documented in the Polar API documentation and
      available in our SDKs.
  - name: private
    description: >-
      Endpoints that should appear in the schema only in development to generate
      our internal JS SDK.
paths:
  /v1/orders/{id}/invoice:
    post:
      tags:
        - orders
        - public
      summary: Generate Order Invoice
      description: |-
        Trigger generation of an order's invoice.

        **Scopes**: `orders:read`
      operationId: orders:generate_invoice
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid4
            description: The order ID.
            title: Id
          description: The order ID.
      responses:
        '202':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '404':
          description: Order not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResourceNotFound'
        '409':
          description: Order is not eligible for invoice generation (invalid status).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OrderNotEligibleForInvoice'
        '422':
          description: Order is missing billing name or address.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MissingInvoiceBillingDetails'
      security:
        - oidc:
            - orders:read
        - pat:
            - orders:read
        - oat:
            - orders:read
      x-codeSamples:
        - lang: Python (New SDK)
          source: |
            from polar.v2026_04 import Polar

            polar = Polar("polar_oat_xxx")

            response = polar.orders.generate_invoice(
                '00000000-0000-4000-8000-000000000000',
            )
            print(response)
        - lang: TypeScript (New SDK)
          source: |
            import { createPolar } from "@polar-sh/sdk/2026-04";

            const polar = createPolar({
              accessToken: "polar_oat_xxx",
            });

            const response = await polar.orders.generateInvoice(
              "00000000-0000-4000-8000-000000000000",
            );
            console.log(response);
components:
  schemas:
    ResourceNotFound:
      properties:
        error:
          type: string
          const: ResourceNotFound
          title: Error
          examples:
            - ResourceNotFound
        detail:
          type: string
          title: Detail
      type: object
      required:
        - error
        - detail
      title: ResourceNotFound
    OrderNotEligibleForInvoice:
      properties:
        error:
          type: string
          const: OrderNotEligibleForInvoice
          title: Error
          examples:
            - OrderNotEligibleForInvoice
        detail:
          type: string
          title: Detail
      type: object
      required:
        - error
        - detail
      title: OrderNotEligibleForInvoice
    MissingInvoiceBillingDetails:
      properties:
        error:
          type: string
          const: MissingInvoiceBillingDetails
          title: Error
          examples:
            - MissingInvoiceBillingDetails
        detail:
          type: string
          title: Detail
      type: object
      required:
        - error
        - detail
      title: MissingInvoiceBillingDetails
  securitySchemes:
    oidc:
      type: openIdConnect
      openIdConnectUrl: /.well-known/openid-configuration
    pat:
      type: http
      description: >-
        You can generate a **Personal Access Token** from your
        [settings](https://polar.sh/settings).
      scheme: bearer
    oat:
      type: http
      description: >-
        You can generate an **Organization Access Token** from your
        organization's settings.
      scheme: bearer

````