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

# Finalize Invoice

> Finalizes a draft Stripe invoice, such as one left in draft by invoice mode with finalize set to false. Stripe then collects it: a send-invoice invoice is emailed and an automatically-charged one is charged. Any plan still waiting on the invoice to be paid expires at its due date. Already open or paid invoices are returned unchanged.

### Body Parameters

The Autumn invoice ID to finalize.

finalize opens the invoice without Stripe emailing, reminding or charging. send opens it and Stripe emails it for the customer to pay (send\_invoice). charge\_automatically charges the customer's payment method on file right away, and is refused when there is none. Omitted, the draft is issued the way it is set up: emailed if it is send\_invoice, charged if it is charge\_automatically.

Days the customer has to pay an emailed invoice. Omitted, the draft keeps its due date, falling back to the org default. Only valid with issue\_method send.

If true, returns exactly what finalizing would issue (lines, discounts, tax, credits, amount due) and how it is issued, without changing anything.

### Response

The invoice. Unchanged when preview is true.

**properties**

The Autumn invoice ID

Array of plan IDs included in this invoice

The Stripe invoice ID

The billing processor that owns this invoice.

The status of the invoice

The total amount of the invoice

The amount paid on the invoice, in major currency units. Null on invoices recorded before amounts paid were tracked.

The total amount refunded on the invoice, in major currency units

The currency code for the invoice

Timestamp when the invoice was created

URL to the Stripe-hosted invoice page

The ID of the customer this invoice belongs to. Null for customers created without an ID.

The ID of the entity this invoice belongs to, if entity-scoped

Line items on the invoice, one per line as shown in Stripe. Capped at 100. Empty for invoices recorded before line item storage.

**properties**

The Autumn invoice line item ID. Stable across reads, and can be used to reference this line in later calls.

Description of the invoice line item

Timestamp when the billing period starts

Timestamp when the billing period ends

The plan this line item came from. Null for lines with no Autumn plan behind them.

The ID of the feature associated with this line item

The name of the feature associated with this line item

Quantity actually charged on this line. Null on fixed-price lines.

Amount charged on this line, pre-discount and pre-tax. Negative for credits.

How this line splits by entity. Empty for customer-level lines. Only populated for invoices finalized after entity attribution shipped.

**properties**

The entity this share of the line item is attributed to

Quantity charged to this entity. Null on fixed-price lines.

Amount attributed to this entity, pre-discount and pre-tax

Total discounts on the invoice, worked out from its stored line items. Absent when the invoice has none stored.

Tax added on top of the discounted line items (total less the lines after discounts). Absent when the invoice has no stored line items.

What finalizing issues. Returned when preview is true.

**properties**

**properties**

The entity this line is billed to. Null for customer-level lines.

**properties**

The customer's Stripe credit balance and how much of it this invoice consumes.

**properties**

Stripe customer credit balance available, expressed as a positive number in major currency units.

How much of that balance this invoice consumes, capped at its total. The rest stays on the customer.

Three-letter currency code.

What the customer pays: the total less any credit applied.

How the invoice is issued on approval: finalize (opened, not emailed or charged), send (emailed) or charge\_automatically (charged to the payment method on file).

The payment method charged when issue\_method is charge\_automatically. Null otherwise, or when the customer has none.

**properties**

Stripe payment method type, e.g. card.

True when issue\_method is charge\_automatically but the customer has no payment method, so finalizing is refused. Add one, or use send.

Where Stripe emails the invoice when issue\_method is send.

True when the invoice is already open or paid, so finalizing changes nothing.

Set when issue\_method charge\_automatically finalized the invoice but the charge failed (payment\_failed). The invoice stays open and unpaid, and Stripe retries it.

**properties**

The type of action required to complete the payment.

A human-readable explanation of why this action is required.

```json 200 theme={null}
{
  "invoice": {
    "id": "inv_2b3c4d5e6f7g8h",
    "customer_id": "cus_123",
    "entity_id": null,
    "plan_ids": [
      "pro_plan"
    ],
    "stripe_id": "in_1A2B3C4D5E6F7G8H",
    "processor_type": "stripe",
    "status": "open",
    "total": 29.99,
    "amount_paid": 29.99,
    "refunded_amount": 0,
    "currency": "usd",
    "created_at": 1759247877000,
    "hosted_invoice_url": "https://invoice.stripe.com/i/acct_123/test_456",
    "items": [
      {
        "id": "invoice_li_2b3c4d5e6f7g8h",
        "description": "Pro plan",
        "plan_id": "pro_plan",
        "feature_id": null,
        "feature_name": null,
        "quantity": null,
        "amount": 20,
        "period_start": 1759247877000,
        "period_end": 1761839877000,
        "entities": []
      },
      {
        "id": "invoice_li_3c4d5e6f7g8h9i",
        "description": "AI credits",
        "plan_id": "pro_plan",
        "feature_id": "ai_credits",
        "feature_name": "AI Credits",
        "quantity": 4995,
        "amount": 9.99,
        "period_start": 1759247877000,
        "period_end": 1761839877000,
        "entities": [
          {
            "entity_id": "acme-docs-prod",
            "quantity": 4995,
            "amount": 9.99
          }
        ]
      }
    ]
  }
}
```


## OpenAPI

````yaml openapi POST /v1/invoices.finalize
openapi: 3.1.0
info:
  title: Autumn API
  version: 2.6.0
servers:
  - url: https://api.useautumn.com
    description: Production server
security:
  - secretKey: []
paths:
  /v1/invoices.finalize:
    post:
      tags:
        - invoices
      description: >-
        Finalizes a draft Stripe invoice, such as one left in draft by invoice
        mode with finalize set to false. Stripe then collects it: a send-invoice
        invoice is emailed and an automatically-charged one is charged. Any plan
        still waiting on the invoice to be paid expires at its due date. Already
        open or paid invoices are returned unchanged.
      operationId: finalizeInvoice
      parameters:
        - name: x-api-version
          in: header
          required: true
          schema:
            type: string
            default: 2.6.0
          x-speakeasy-globals-hidden: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                invoice_id:
                  type: string
                  description: The Autumn invoice ID to finalize.
                issue_method:
                  enum:
                    - finalize
                    - send
                    - charge_automatically
                  type: string
                  description: >-
                    finalize opens the invoice without Stripe emailing,
                    reminding or charging. send opens it and Stripe emails it
                    for the customer to pay (send_invoice). charge_automatically
                    charges the customer's payment method on file right away,
                    and is refused when there is none. Omitted, the draft is
                    issued the way it is set up: emailed if it is send_invoice,
                    charged if it is charge_automatically.
                net_terms_days:
                  type: integer
                  minimum: -9007199254740991
                  maximum: 9007199254740991
                  exclusiveMinimum: 0
                  description: >-
                    Days the customer has to pay an emailed invoice. Omitted,
                    the draft keeps its due date, falling back to the org
                    default. Only valid with issue_method send.
                preview:
                  type: boolean
                  description: >-
                    If true, returns exactly what finalizing would issue (lines,
                    discounts, tax, credits, amount due) and how it is issued,
                    without changing anything.
              required:
                - invoice_id
              title: FinalizeInvoiceParams
              examples:
                - invoice_id: inv_2b3c4d5e6f7g8h
            example:
              invoice_id: inv_2b3c4d5e6f7g8h
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  invoice:
                    type: object
                    properties:
                      id:
                        type: string
                        description: The Autumn invoice ID
                      plan_ids:
                        type: array
                        items:
                          type: string
                        description: Array of plan IDs included in this invoice
                      stripe_id:
                        type: string
                        description: The Stripe invoice ID
                      processor_type:
                        enum:
                          - stripe
                          - revenuecat
                        type: string
                        default: stripe
                        description: The billing processor that owns this invoice.
                      status:
                        type: string
                        description: The status of the invoice
                      total:
                        type: number
                        description: The total amount of the invoice
                      amount_paid:
                        anyOf:
                          - type: number
                          - type: 'null'
                        description: >-
                          The amount paid on the invoice, in major currency
                          units. Null on invoices recorded before amounts paid
                          were tracked.
                      refunded_amount:
                        type: number
                        description: >-
                          The total amount refunded on the invoice, in major
                          currency units
                      currency:
                        type: string
                        description: The currency code for the invoice
                      created_at:
                        type: number
                        description: Timestamp when the invoice was created
                      hosted_invoice_url:
                        anyOf:
                          - type: string
                          - type: 'null'
                        description: URL to the Stripe-hosted invoice page
                      customer_id:
                        anyOf:
                          - type: string
                          - type: 'null'
                        description: >-
                          The ID of the customer this invoice belongs to. Null
                          for customers created without an ID.
                      entity_id:
                        anyOf:
                          - type: string
                          - type: 'null'
                        description: >-
                          The ID of the entity this invoice belongs to, if
                          entity-scoped
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              description: >-
                                The Autumn invoice line item ID. Stable across
                                reads, and can be used to reference this line in
                                later calls.
                            description:
                              type: string
                              description: Description of the invoice line item
                            period_start:
                              anyOf:
                                - type: number
                                - type: 'null'
                              description: Timestamp when the billing period starts
                            period_end:
                              anyOf:
                                - type: number
                                - type: 'null'
                              description: Timestamp when the billing period ends
                            plan_id:
                              anyOf:
                                - type: string
                                - type: 'null'
                              description: >-
                                The plan this line item came from. Null for
                                lines with no Autumn plan behind them.
                            feature_id:
                              anyOf:
                                - type: string
                                - type: 'null'
                              description: >-
                                The ID of the feature associated with this line
                                item
                            feature_name:
                              anyOf:
                                - type: string
                                - type: 'null'
                              description: >-
                                The name of the feature associated with this
                                line item
                            quantity:
                              anyOf:
                                - type: number
                                - type: 'null'
                              description: >-
                                Quantity actually charged on this line. Null on
                                fixed-price lines.
                            amount:
                              type: number
                              description: >-
                                Amount charged on this line, pre-discount and
                                pre-tax. Negative for credits.
                            entities:
                              type: array
                              items:
                                type: object
                                properties:
                                  entity_id:
                                    type: string
                                    description: >-
                                      The entity this share of the line item is
                                      attributed to
                                  quantity:
                                    anyOf:
                                      - type: number
                                      - type: 'null'
                                    description: >-
                                      Quantity charged to this entity. Null on
                                      fixed-price lines.
                                  amount:
                                    type: number
                                    description: >-
                                      Amount attributed to this entity,
                                      pre-discount and pre-tax
                                required:
                                  - entity_id
                                  - quantity
                                  - amount
                              description: >-
                                How this line splits by entity. Empty for
                                customer-level lines. Only populated for
                                invoices finalized after entity attribution
                                shipped.
                          required:
                            - id
                            - description
                            - period_start
                            - period_end
                            - plan_id
                            - feature_id
                            - feature_name
                            - quantity
                            - amount
                            - entities
                        description: >-
                          Line items on the invoice, one per line as shown in
                          Stripe. Capped at 100. Empty for invoices recorded
                          before line item storage.
                      discount_total:
                        type: number
                        description: >-
                          Total discounts on the invoice, worked out from its
                          stored line items. Absent when the invoice has none
                          stored.
                      tax:
                        type: number
                        description: >-
                          Tax added on top of the discounted line items (total
                          less the lines after discounts). Absent when the
                          invoice has no stored line items.
                    required:
                      - id
                      - plan_ids
                      - stripe_id
                      - status
                      - total
                      - amount_paid
                      - refunded_amount
                      - currency
                      - created_at
                      - customer_id
                      - entity_id
                    description: The invoice. Unchanged when preview is true.
                  preview:
                    type: object
                    properties:
                      currency:
                        type: string
                      lines:
                        type: array
                        items:
                          type: object
                          properties:
                            plan_id:
                              anyOf:
                                - type: string
                                - type: 'null'
                            feature_id:
                              anyOf:
                                - type: string
                                - type: 'null'
                            entity_id:
                              anyOf:
                                - type: string
                                - type: 'null'
                              description: >-
                                The entity this line is billed to. Null for
                                customer-level lines.
                            description:
                              type: string
                            amount:
                              type: number
                            amount_after_discounts:
                              type: number
                            quantity:
                              anyOf:
                                - type: number
                                - type: 'null'
                            prorated:
                              type: boolean
                            period_start:
                              anyOf:
                                - type: number
                                - type: 'null'
                            period_end:
                              anyOf:
                                - type: number
                                - type: 'null'
                          required:
                            - plan_id
                            - feature_id
                            - entity_id
                            - description
                            - amount
                            - amount_after_discounts
                            - quantity
                            - prorated
                            - period_start
                            - period_end
                      subtotal:
                        type: number
                      discount_total:
                        type: number
                      tax:
                        anyOf:
                          - type: object
                            properties:
                              total:
                                type: number
                              amount_inclusive:
                                type: number
                              amount_exclusive:
                                type: number
                              status:
                                enum:
                                  - complete
                                  - incomplete
                                  - requires_location
                                type: string
                            required:
                              - total
                              - amount_inclusive
                              - amount_exclusive
                              - status
                          - type: 'null'
                      total:
                        type: number
                      invoice_credits:
                        type: object
                        properties:
                          balance:
                            type: number
                            description: >-
                              Stripe customer credit balance available,
                              expressed as a positive number in major currency
                              units.
                          applied:
                            type: number
                            description: >-
                              How much of that balance this invoice consumes,
                              capped at its total. The rest stays on the
                              customer.
                          currency:
                            type: string
                            description: Three-letter currency code.
                        required:
                          - balance
                          - currency
                        description: >-
                          The customer's Stripe credit balance and how much of
                          it this invoice consumes.
                      amount_due:
                        type: number
                        description: >-
                          What the customer pays: the total less any credit
                          applied.
                      issue_date:
                        type: number
                      due_date:
                        anyOf:
                          - type: number
                          - type: 'null'
                      issue_method:
                        enum:
                          - finalize
                          - send
                          - charge_automatically
                        type: string
                        description: >-
                          How the invoice is issued on approval: finalize
                          (opened, not emailed or charged), send (emailed) or
                          charge_automatically (charged to the payment method on
                          file).
                      payment_method:
                        anyOf:
                          - type: object
                            properties:
                              id:
                                type: string
                              type:
                                type: string
                                description: Stripe payment method type, e.g. card.
                              brand:
                                anyOf:
                                  - type: string
                                  - type: 'null'
                              last4:
                                anyOf:
                                  - type: string
                                  - type: 'null'
                            required:
                              - id
                              - type
                              - brand
                              - last4
                          - type: 'null'
                        description: >-
                          The payment method charged when issue_method is
                          charge_automatically. Null otherwise, or when the
                          customer has none.
                      requires_payment_method:
                        type: boolean
                        description: >-
                          True when issue_method is charge_automatically but the
                          customer has no payment method, so finalizing is
                          refused. Add one, or use send.
                      customer_email:
                        anyOf:
                          - type: string
                          - type: 'null'
                        description: >-
                          Where Stripe emails the invoice when issue_method is
                          send.
                      already_finalized:
                        type: boolean
                        description: >-
                          True when the invoice is already open or paid, so
                          finalizing changes nothing.
                    required:
                      - currency
                      - lines
                      - subtotal
                      - discount_total
                      - tax
                      - total
                      - amount_due
                      - issue_date
                      - due_date
                      - issue_method
                      - payment_method
                      - requires_payment_method
                      - customer_email
                      - already_finalized
                    description: What finalizing issues. Returned when preview is true.
                  required_action:
                    type: object
                    properties:
                      code:
                        enum:
                          - 3ds_required
                          - payment_method_required
                          - payment_failed
                          - payment_processing
                        type: string
                        description: The type of action required to complete the payment.
                      reason:
                        type: string
                        description: >-
                          A human-readable explanation of why this action is
                          required.
                    required:
                      - code
                      - reason
                    description: >-
                      Set when issue_method charge_automatically finalized the
                      invoice but the charge failed (payment_failed). The
                      invoice stays open and unpaid, and Stripe retries it.
                required:
                  - invoice
                examples:
                  - invoice:
                      id: inv_2b3c4d5e6f7g8h
                      customer_id: cus_123
                      entity_id: null
                      plan_ids:
                        - pro_plan
                      stripe_id: in_1A2B3C4D5E6F7G8H
                      processor_type: stripe
                      status: open
                      total: 29.99
                      amount_paid: 29.99
                      refunded_amount: 0
                      currency: usd
                      created_at: 1759247877000
                      hosted_invoice_url: https://invoice.stripe.com/i/acct_123/test_456
                      items:
                        - id: invoice_li_2b3c4d5e6f7g8h
                          description: Pro plan
                          plan_id: pro_plan
                          feature_id: null
                          feature_name: null
                          quantity: null
                          amount: 20
                          period_start: 1759247877000
                          period_end: 1761839877000
                          entities: []
                        - id: invoice_li_3c4d5e6f7g8h9i
                          description: AI credits
                          plan_id: pro_plan
                          feature_id: ai_credits
                          feature_name: AI Credits
                          quantity: 4995
                          amount: 9.99
                          period_start: 1759247877000
                          period_end: 1761839877000
                          entities:
                            - entity_id: acme-docs-prod
                              quantity: 4995
                              amount: 9.99
              example:
                invoice:
                  id: inv_2b3c4d5e6f7g8h
                  customer_id: cus_123
                  entity_id: null
                  plan_ids:
                    - pro_plan
                  stripe_id: in_1A2B3C4D5E6F7G8H
                  processor_type: stripe
                  status: open
                  total: 29.99
                  amount_paid: 29.99
                  refunded_amount: 0
                  currency: usd
                  created_at: 1759247877000
                  hosted_invoice_url: https://invoice.stripe.com/i/acct_123/test_456
                  items:
                    - id: invoice_li_2b3c4d5e6f7g8h
                      description: Pro plan
                      plan_id: pro_plan
                      feature_id: null
                      feature_name: null
                      quantity: null
                      amount: 20
                      period_start: 1759247877000
                      period_end: 1761839877000
                      entities: []
                    - id: invoice_li_3c4d5e6f7g8h9i
                      description: AI credits
                      plan_id: pro_plan
                      feature_id: ai_credits
                      feature_name: AI Credits
                      quantity: 4995
                      amount: 9.99
                      period_start: 1759247877000
                      period_end: 1761839877000
                      entities:
                        - entity_id: acme-docs-prod
                          quantity: 4995
                          amount: 9.99
      x-codeSamples:
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { Autumn } from 'autumn-js'

            const autumn = new Autumn()

            const result = await autumn.invoices.finalize({
              invoiceId: "inv_2b3c4d5e6f7g8h",
            });
        - lang: python
          label: Python (SDK)
          source: |-
            from autumn_sdk import Autumn

            autumn = Autumn(secret_key="am_sk_test...")

            res = autumn.invoices.finalize(
                invoice_id="inv_2b3c4d5e6f7g8h",
            )
components:
  securitySchemes:
    secretKey:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.