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

# Issue Credit Note

> Issues a Stripe credit note against an open or paid invoice, for a flat amount or for specific invoice lines. On an open invoice the credit reduces what is still owed. On a paid invoice the credited money goes to the chosen destination: the customer's balance (default), a refund, or a record of money returned outside Stripe. Line amounts are pre-discount and pre-tax, like the invoice's own item amounts. Pass preview to see the credit note without issuing it.

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 credit. Must be open or paid.
</DynamicParamField>

<DynamicParamField body="amount" type="number">
  Total to credit across the whole invoice. Cannot be combined with lines.
</DynamicParamField>

<DynamicParamField body="lines" type="object[]">
  Credit specific invoice lines instead of a flat amount. Cannot be combined with amount. Unavailable on invoices recorded before line item storage.

  <Expandable title="properties">
    <DynamicParamField body="id" type="string" required>
      The invoice line item ID (invoice\_li\_...) from the invoice's items.
    </DynamicParamField>

    <DynamicParamField body="amount" type="number">
      Amount to credit on this line, pre-discount and pre-tax like the line's own amount. The line's discount share and tax are applied on top.
    </DynamicParamField>

    <DynamicParamField body="quantity" type="number">
      Number of units of this line to credit.
    </DynamicParamField>
  </Expandable>
</DynamicParamField>

<DynamicParamField body="destination" type="'customer_balance' | 'refund' | 'out_of_band'">
  Where already-paid money goes. customer\_balance credits the customer's balance for their next invoice, refund returns it to the original payment method, and out\_of\_band records money returned outside Stripe.
</DynamicParamField>

<DynamicParamField body="send_email" type="boolean">
  Email the credit note to the customer.
</DynamicParamField>

<DynamicParamField body="reason" type="'duplicate' | 'fraudulent' | 'order_change' | 'product_unsatisfactory'">
  Reason shown on the credit note.
</DynamicParamField>

<DynamicParamField body="memo" type="string">
  Memo printed on the credit note PDF.
</DynamicParamField>

<DynamicParamField body="preview" type="boolean">
  Return the credit note that would be issued without creating it.
</DynamicParamField>

### Response

<DynamicResponseField name="credit_note" type="object">
  <Expandable title="properties">
    <DynamicResponseField name="id" type="string | null">
      The Stripe credit note ID. Null on previews.
    </DynamicResponseField>

    <DynamicResponseField name="invoice_id" type="string">
      The Autumn invoice ID this credit note adjusts.
    </DynamicResponseField>

    <DynamicResponseField name="number" type="string | null">
      Credit note number shown on the PDF. Null on previews.
    </DynamicResponseField>

    <DynamicResponseField name="status" type="string | null">
      issued or void. Null on previews.
    </DynamicResponseField>

    <DynamicResponseField name="currency" type="string" />

    <DynamicResponseField name="subtotal" type="number" />

    <DynamicResponseField name="discount_amount" type="number" />

    <DynamicResponseField name="tax_amount" type="number" />

    <DynamicResponseField name="total" type="number">
      Total credited, including discounts and tax.
    </DynamicResponseField>

    <DynamicResponseField name="pre_payment_amount" type="number">
      Portion that reduced the amount still owed on the invoice.
    </DynamicResponseField>

    <DynamicResponseField name="post_payment_amount" type="number">
      Portion of already-paid money returned to the customer.
    </DynamicResponseField>

    <DynamicResponseField name="refund_amount" type="number" />

    <DynamicResponseField name="credit_amount" type="number" />

    <DynamicResponseField name="out_of_band_amount" type="number" />

    <DynamicResponseField name="reason" type="'duplicate' | 'fraudulent' | 'order_change' | 'product_unsatisfactory'" />

    <DynamicResponseField name="memo" type="string | null" />

    <DynamicResponseField name="pdf" type="string | null">
      URL of the credit note PDF. Null on previews.
    </DynamicResponseField>

    <DynamicResponseField name="lines" type="object[]">
      <Expandable title="properties">
        <DynamicResponseField name="invoice_line_item_id" type="string | null">
          The credited invoice line item ID, if the credit targeted a line.
        </DynamicResponseField>

        <DynamicResponseField name="description" type="string | null" />

        <DynamicResponseField name="quantity" type="number | null" />

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

        <DynamicResponseField name="discount_amount" type="number" />
      </Expandable>
    </DynamicResponseField>
  </Expandable>
</DynamicResponseField>

<ResponseExample>
  ```json 200 theme={null}
  {
    "credit_note": {
      "id": "cn_1MxvRqLkdIwHu7ixY0xbUcxk",
      "invoice_id": "inv_2b3c4d5e6f7g8h",
      "number": "ABC-0001-CN-01",
      "status": "issued",
      "currency": "usd",
      "subtotal": 20,
      "discount_amount": 0,
      "tax_amount": 0,
      "total": 20,
      "pre_payment_amount": 0,
      "post_payment_amount": 20,
      "refund_amount": 20,
      "credit_amount": 0,
      "out_of_band_amount": 0,
      "reason": "product_unsatisfactory",
      "memo": "Partial refund for degraded service",
      "pdf": "https://pay.stripe.com/credit_notes/acct_123/test_456/pdf",
      "lines": [
        {
          "invoice_line_item_id": "invoice_li_2b3c4d5e6f7g8h",
          "description": "Pro plan",
          "quantity": null,
          "amount": 20,
          "discount_amount": 0
        }
      ]
    }
  }
  ```
</ResponseExample>


## OpenAPI

````yaml openapi POST /v1/invoices.issue_credit_note
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.issue_credit_note:
    post:
      tags:
        - invoices
      description: >-
        Issues a Stripe credit note against an open or paid invoice, for a flat
        amount or for specific invoice lines. On an open invoice the credit
        reduces what is still owed. On a paid invoice the credited money goes to
        the chosen destination: the customer's balance (default), a refund, or a
        record of money returned outside Stripe. Line amounts are pre-discount
        and pre-tax, like the invoice's own item amounts. Pass preview to see
        the credit note without issuing it.
      operationId: issueCreditNote
      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 credit. Must be open or paid.
                amount:
                  type: number
                  exclusiveMinimum: 0
                  description: >-
                    Total to credit across the whole invoice. Cannot be combined
                    with lines.
                lines:
                  type: array
                  minItems: 1
                  items:
                    type: object
                    properties:
                      id:
                        type: string
                        description: >-
                          The invoice line item ID (invoice_li_...) from the
                          invoice's items.
                      amount:
                        type: number
                        exclusiveMinimum: 0
                        description: >-
                          Amount to credit on this line, pre-discount and
                          pre-tax like the line's own amount. The line's
                          discount share and tax are applied on top.
                      quantity:
                        type: number
                        exclusiveMinimum: 0
                        description: Number of units of this line to credit.
                    required:
                      - id
                    additionalProperties: false
                  description: >-
                    Credit specific invoice lines instead of a flat amount.
                    Cannot be combined with amount. Unavailable on invoices
                    recorded before line item storage.
                destination:
                  enum:
                    - customer_balance
                    - refund
                    - out_of_band
                  type: string
                  description: >-
                    Where already-paid money goes. customer_balance credits the
                    customer's balance for their next invoice, refund returns it
                    to the original payment method, and out_of_band records
                    money returned outside Stripe.
                  default: customer_balance
                send_email:
                  type: boolean
                  default: true
                  description: Email the credit note to the customer.
                reason:
                  enum:
                    - duplicate
                    - fraudulent
                    - order_change
                    - product_unsatisfactory
                  type: string
                  description: Reason shown on the credit note.
                memo:
                  type: string
                  description: Memo printed on the credit note PDF.
                preview:
                  type: boolean
                  description: >-
                    Return the credit note that would be issued without creating
                    it.
              required:
                - invoice_id
              additionalProperties: false
              title: IssueCreditNoteParams
              examples:
                - invoice_id: inv_2b3c4d5e6f7g8h
                  lines:
                    - id: invoice_li_2b3c4d5e6f7g8h
                      amount: 20
                  destination: refund
                  send_email: true
                  reason: product_unsatisfactory
                  memo: Partial refund for degraded service
            example:
              invoice_id: inv_2b3c4d5e6f7g8h
              lines:
                - id: invoice_li_2b3c4d5e6f7g8h
                  amount: 20
              destination: refund
              send_email: true
              reason: product_unsatisfactory
              memo: Partial refund for degraded service
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  credit_note:
                    type: object
                    properties:
                      id:
                        anyOf:
                          - type: string
                          - type: 'null'
                        description: The Stripe credit note ID. Null on previews.
                      invoice_id:
                        type: string
                        description: The Autumn invoice ID this credit note adjusts.
                      number:
                        anyOf:
                          - type: string
                          - type: 'null'
                        description: Credit note number shown on the PDF. Null on previews.
                      status:
                        anyOf:
                          - type: string
                          - type: 'null'
                        description: issued or void. Null on previews.
                      currency:
                        type: string
                      subtotal:
                        type: number
                      discount_amount:
                        type: number
                      tax_amount:
                        type: number
                      total:
                        type: number
                        description: Total credited, including discounts and tax.
                      pre_payment_amount:
                        type: number
                        description: >-
                          Portion that reduced the amount still owed on the
                          invoice.
                      post_payment_amount:
                        type: number
                        description: >-
                          Portion of already-paid money returned to the
                          customer.
                      refund_amount:
                        type: number
                      credit_amount:
                        type: number
                      out_of_band_amount:
                        type: number
                      reason:
                        anyOf:
                          - enum:
                              - duplicate
                              - fraudulent
                              - order_change
                              - product_unsatisfactory
                            type: string
                          - type: 'null'
                      memo:
                        anyOf:
                          - type: string
                          - type: 'null'
                      pdf:
                        anyOf:
                          - type: string
                          - type: 'null'
                        description: URL of the credit note PDF. Null on previews.
                      lines:
                        type: array
                        items:
                          type: object
                          properties:
                            invoice_line_item_id:
                              anyOf:
                                - type: string
                                - type: 'null'
                              description: >-
                                The credited invoice line item ID, if the credit
                                targeted a line.
                            description:
                              anyOf:
                                - type: string
                                - type: 'null'
                            quantity:
                              anyOf:
                                - type: number
                                - type: 'null'
                            amount:
                              type: number
                              description: >-
                                Amount credited on this line, pre-discount and
                                pre-tax.
                            discount_amount:
                              type: number
                          required:
                            - invoice_line_item_id
                            - description
                            - quantity
                            - amount
                            - discount_amount
                    required:
                      - id
                      - invoice_id
                      - number
                      - status
                      - currency
                      - subtotal
                      - discount_amount
                      - tax_amount
                      - total
                      - pre_payment_amount
                      - post_payment_amount
                      - refund_amount
                      - credit_amount
                      - out_of_band_amount
                      - reason
                      - memo
                      - pdf
                      - lines
                required:
                  - credit_note
                examples:
                  - credit_note:
                      id: cn_1MxvRqLkdIwHu7ixY0xbUcxk
                      invoice_id: inv_2b3c4d5e6f7g8h
                      number: ABC-0001-CN-01
                      status: issued
                      currency: usd
                      subtotal: 20
                      discount_amount: 0
                      tax_amount: 0
                      total: 20
                      pre_payment_amount: 0
                      post_payment_amount: 20
                      refund_amount: 20
                      credit_amount: 0
                      out_of_band_amount: 0
                      reason: product_unsatisfactory
                      memo: Partial refund for degraded service
                      pdf: >-
                        https://pay.stripe.com/credit_notes/acct_123/test_456/pdf
                      lines:
                        - invoice_line_item_id: invoice_li_2b3c4d5e6f7g8h
                          description: Pro plan
                          quantity: null
                          amount: 20
                          discount_amount: 0
              example:
                credit_note:
                  id: cn_1MxvRqLkdIwHu7ixY0xbUcxk
                  invoice_id: inv_2b3c4d5e6f7g8h
                  number: ABC-0001-CN-01
                  status: issued
                  currency: usd
                  subtotal: 20
                  discount_amount: 0
                  tax_amount: 0
                  total: 20
                  pre_payment_amount: 0
                  post_payment_amount: 20
                  refund_amount: 20
                  credit_amount: 0
                  out_of_band_amount: 0
                  reason: product_unsatisfactory
                  memo: Partial refund for degraded service
                  pdf: https://pay.stripe.com/credit_notes/acct_123/test_456/pdf
                  lines:
                    - invoice_line_item_id: invoice_li_2b3c4d5e6f7g8h
                      description: Pro plan
                      quantity: null
                      amount: 20
                      discount_amount: 0
      x-codeSamples:
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { Autumn } from 'autumn-js'

            const autumn = new Autumn()

            const result = await autumn.invoices.issueCreditNote({
              invoiceId: "inv_2b3c4d5e6f7g8h",
              lines: [
                {
                  id: "invoice_li_2b3c4d5e6f7g8h",
                  amount: 20,
                },
              ],
              destination: "refund",
              reason: "product_unsatisfactory",
              memo: "Partial refund for degraded service",
            });
        - lang: python
          label: Python (SDK)
          source: |-
            from autumn_sdk import Autumn

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

            res = autumn.invoices.issue_credit_note(
                invoice_id="inv_2b3c4d5e6f7g8h",
                lines=[
                    {
                        "id": "invoice_li_2b3c4d5e6f7g8h",
                        "amount": 20,
                    },
                ],
                destination="refund",
                send_email=True,
                reason="product_unsatisfactory",
                memo="Partial refund for degraded service",
            )
components:
  securitySchemes:
    secretKey:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

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