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

# Pay Invoice

> Marks an open Stripe invoice as paid out of band. No charge is attempted; use this when payment was collected elsewhere (e.g. a marketplace). Already-paid invoices are returned unchanged.

export const DynamicResponseExample = ({json, statusCode = "200"}) => {
  const toCamelCase = str => {
    return str.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
  };
  const convertKeysToCamelCase = obj => {
    if (Array.isArray(obj)) {
      return obj.map(item => convertKeysToCamelCase(item));
    }
    if (obj !== null && typeof obj === "object") {
      return Object.keys(obj).reduce((acc, key) => {
        const camelKey = toCamelCase(key);
        acc[camelKey] = convertKeysToCamelCase(obj[key]);
        return acc;
      }, {});
    }
    return obj;
  };
  const [isTypeScript, setIsTypeScript] = useState(() => {
    if (typeof window !== "undefined") {
      try {
        const lang = localStorage.getItem("code");
        return JSON.parse(lang) === "typescript";
      } catch {
        return true;
      }
    }
    return true;
  });
  useEffect(() => {
    const onMintlifyStorage = event => {
      if (event.detail?.key === "code") {
        try {
          const value = JSON.parse(event.detail.value);
          setIsTypeScript(value === "typescript");
        } catch {}
      }
    };
    const pollInterval = setInterval(() => {
      try {
        const lang = localStorage.getItem("code");
        const value = JSON.parse(lang);
        setIsTypeScript(value === "typescript");
      } catch {}
    }, 300);
    document.addEventListener("mintlify-localstorage", onMintlifyStorage);
    return () => {
      document.removeEventListener("mintlify-localstorage", onMintlifyStorage);
      clearInterval(pollInterval);
    };
  }, []);
  const camelCaseJson = useMemo(() => convertKeysToCamelCase(json), [json]);
  const snakeCaseString = JSON.stringify(json, null, 2);
  const camelCaseString = JSON.stringify(camelCaseJson, null, 2);
  return <ResponseExample>
			{isTypeScript ? <CodeBlock language="json" filename={statusCode}>
					{camelCaseString}
				</CodeBlock> : <CodeBlock language="json" filename={statusCode}>
					{snakeCaseString}
				</CodeBlock>}
		</ResponseExample>;
};

export const DynamicResponseField = ({children, name, ...props}) => {
  const convertToCamelCase = str => {
    if (typeof str !== "string") return str;
    return str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase());
  };
  const [lang, setLang] = useState(() => {
    if (typeof window !== "undefined") {
      const stored = localStorage.getItem("code");
      return stored || '"typescript"';
    }
    return '"typescript"';
  });
  useEffect(() => {
    const onMintlifyStorage = event => {
      const key = event.detail?.key;
      if (key === "code") {
        setLang(event.detail.value);
      }
    };
    const pollInterval = setInterval(() => {
      const current = localStorage.getItem("code");
      if (current && current !== lang) {
        setLang(current);
      }
    }, 500);
    document.addEventListener("mintlify-localstorage", onMintlifyStorage);
    return () => {
      document.removeEventListener("mintlify-localstorage", onMintlifyStorage);
      clearInterval(pollInterval);
    };
  }, [lang]);
  const resolvedName = useMemo(() => {
    try {
      const value = JSON.parse(lang);
      const useCamelCase = value === "typescript";
      return useCamelCase ? convertToCamelCase(name) : name;
    } catch {
      return name;
    }
  }, [name, lang]);
  return <ResponseField name={resolvedName} {...props}>
			{children}
		</ResponseField>;
};

export const DynamicParamField = ({children, body, path, ...props}) => {
  const convertToCamelCase = str => {
    if (typeof str !== "string") return str;
    return str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase());
  };
  const [lang, setLang] = useState(() => {
    if (typeof window !== "undefined") {
      const stored = localStorage.getItem("code");
      return stored || '"typescript"';
    }
    return '"typescript"';
  });
  useEffect(() => {
    const onMintlifyStorage = event => {
      const key = event.detail?.key;
      if (key === "code") {
        setLang(event.detail.value);
      }
    };
    const pollInterval = setInterval(() => {
      const current = localStorage.getItem("code");
      if (current && current !== lang) {
        setLang(current);
      }
    }, 500);
    document.addEventListener("mintlify-localstorage", onMintlifyStorage);
    return () => {
      document.removeEventListener("mintlify-localstorage", onMintlifyStorage);
      clearInterval(pollInterval);
    };
  }, [lang]);
  const resolvedBody = useMemo(() => {
    try {
      const value = JSON.parse(lang);
      const useCamelCase = value === "typescript";
      return useCamelCase ? convertToCamelCase(body) : body;
    } catch {
      return body;
    }
  }, [body, lang]);
  const resolvedPath = useMemo(() => {
    try {
      const value = JSON.parse(lang);
      const useCamelCase = value === "typescript";
      return useCamelCase ? convertToCamelCase(path) : path;
    } catch {
      return path;
    }
  }, [path, lang]);
  return <ParamField body={resolvedBody} path={resolvedPath} {...props}>
			{children}
		</ParamField>;
};

### Body Parameters

<DynamicParamField body="invoice_id" type="string" required>
  The Autumn invoice ID to mark as paid.
</DynamicParamField>

### Response

<DynamicResponseField name="invoice" type="object">
  <Expandable title="properties">
    <DynamicResponseField name="plan_ids" type="string[]">
      Array of plan IDs included in this invoice
    </DynamicResponseField>

    <DynamicResponseField name="stripe_id" type="string">
      The Stripe invoice ID
    </DynamicResponseField>

    <DynamicResponseField name="processor_type" type="'stripe' | 'revenuecat'">
      The billing processor that owns this invoice.
    </DynamicResponseField>

    <DynamicResponseField name="status" type="string">
      The status of the invoice
    </DynamicResponseField>

    <DynamicResponseField name="total" type="number">
      The total amount of the invoice
    </DynamicResponseField>

    <DynamicResponseField name="currency" type="string">
      The currency code for the invoice
    </DynamicResponseField>

    <DynamicResponseField name="created_at" type="number">
      Timestamp when the invoice was created
    </DynamicResponseField>

    <DynamicResponseField name="hosted_invoice_url" type="string | null">
      URL to the Stripe-hosted invoice page
    </DynamicResponseField>

    <DynamicResponseField name="id" type="string">
      The Autumn invoice ID
    </DynamicResponseField>

    <DynamicResponseField name="customer_id" type="string | null">
      The ID of the customer this invoice belongs to. Null for customers created without an ID.
    </DynamicResponseField>

    <DynamicResponseField name="entity_id" type="string | null">
      The ID of the entity this invoice belongs to, if entity-scoped
    </DynamicResponseField>

    <DynamicResponseField name="amount_paid" type="number | null">
      The amount paid on the invoice. Null on invoices recorded before amounts paid were tracked.
    </DynamicResponseField>

    <DynamicResponseField name="refunded_amount" type="number">
      The total amount refunded on the invoice
    </DynamicResponseField>

    <DynamicResponseField name="items" type="object[]">
      Line items on the invoice, one per line as shown in Stripe. Capped at 100. Empty for invoices recorded before line item storage.

      <Expandable title="properties">
        <DynamicResponseField name="description" type="string">
          Description of the invoice line item
        </DynamicResponseField>

        <DynamicResponseField name="period_start" type="number | null">
          Timestamp when the billing period starts
        </DynamicResponseField>

        <DynamicResponseField name="period_end" type="number | null">
          Timestamp when the billing period ends
        </DynamicResponseField>

        <DynamicResponseField name="plan_id" type="string | null">
          The plan this line item came from. Null for lines with no Autumn plan behind them.
        </DynamicResponseField>

        <DynamicResponseField name="feature_id" type="string | null">
          The ID of the feature associated with this line item
        </DynamicResponseField>

        <DynamicResponseField name="feature_name" type="string | null">
          The name of the feature associated with this line item
        </DynamicResponseField>

        <DynamicResponseField name="quantity" type="number | null">
          Quantity actually charged on this line. Null on fixed-price lines.
        </DynamicResponseField>

        <DynamicResponseField name="amount" type="number">
          Amount charged on this line, pre-discount and pre-tax. Negative for credits.
        </DynamicResponseField>

        <DynamicResponseField name="entities" type="object[]">
          How this line splits by entity. Empty for customer-level lines. Only populated for invoices finalized after entity attribution shipped.

          <Expandable title="properties">
            <DynamicResponseField name="entity_id" type="string">
              The entity this share of the line item is attributed to
            </DynamicResponseField>

            <DynamicResponseField name="quantity" type="number | null">
              Quantity charged to this entity. Null on fixed-price lines.
            </DynamicResponseField>

            <DynamicResponseField name="amount" type="number">
              Amount attributed to this entity, pre-discount and pre-tax
            </DynamicResponseField>
          </Expandable>
        </DynamicResponseField>
      </Expandable>
    </DynamicResponseField>
  </Expandable>
</DynamicResponseField>

<ResponseExample>
  ```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": "paid",
      "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": [
        {
          "description": "Pro plan",
          "plan_id": "pro_plan",
          "feature_id": null,
          "feature_name": null,
          "quantity": null,
          "amount": 20,
          "period_start": 1759247877000,
          "period_end": 1761839877000,
          "entities": []
        },
        {
          "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
            }
          ]
        }
      ]
    }
  }
  ```
</ResponseExample>


## OpenAPI

````yaml openapi POST /v1/invoices.pay
openapi: 3.1.0
info:
  title: Autumn API
  version: 2.4.0
servers:
  - url: https://api.useautumn.com
    description: Production server
security:
  - secretKey: []
paths:
  /v1/invoices.pay:
    post:
      tags:
        - invoices
      description: >-
        Marks an open Stripe invoice as paid out of band. No charge is
        attempted; use this when payment was collected elsewhere (e.g. a
        marketplace). Already-paid invoices are returned unchanged.
      operationId: payInvoice
      parameters:
        - name: x-api-version
          in: header
          required: true
          schema:
            type: string
            default: 2.4.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 mark as paid.
              required:
                - invoice_id
              title: PayInvoiceParams
              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:
                      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
                      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
                      id:
                        type: string
                        description: The Autumn invoice ID
                      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
                      amount_paid:
                        anyOf:
                          - type: number
                          - type: 'null'
                        description: >-
                          The amount paid on the invoice. Null on invoices
                          recorded before amounts paid were tracked.
                      refunded_amount:
                        type: number
                        description: The total amount refunded on the invoice
                      items:
                        type: array
                        items:
                          type: object
                          properties:
                            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:
                            - 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.
                    required:
                      - plan_ids
                      - stripe_id
                      - status
                      - total
                      - currency
                      - created_at
                      - id
                      - customer_id
                      - entity_id
                      - amount_paid
                      - refunded_amount
                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: paid
                      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:
                        - description: Pro plan
                          plan_id: pro_plan
                          feature_id: null
                          feature_name: null
                          quantity: null
                          amount: 20
                          period_start: 1759247877000
                          period_end: 1761839877000
                          entities: []
                        - 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: paid
                  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:
                    - description: Pro plan
                      plan_id: pro_plan
                      feature_id: null
                      feature_name: null
                      quantity: null
                      amount: 20
                      period_start: 1759247877000
                      period_end: 1761839877000
                      entities: []
                    - 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.pay({
              invoiceId: "inv_2b3c4d5e6f7g8h",
            });
components:
  securitySchemes:
    secretKey:
      type: http
      scheme: bearer
      bearerFormat: JWT

````