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

# Credit an invoice

> Creates a draft credit note against an invoice, crediting it at the prices and tax it was issued with rather than calculating tax again. Omit `line_items` to credit everything still uncredited on the invoice. Give `line_items` to credit specific invoice lines, each by the `quantity` of units to credit, which may be fractional. Every line here credits an invoice line item; to credit an amount that is not on the invoice, use create-credit-note instead.



## OpenAPI

````yaml /api-reference/v2/specs/2026-04-01.json post /invoices/{id}/credit-notes
openapi: 3.1.0
info:
  title: Alguna Public API
  version: '2026-04-01'
servers:
  - url: https://api.alguna.io
security:
  - bearerAuth: []
tags:
  - name: Billing Events and Metrics
  - name: Checkout Sessions
  - name: Credit Notes
  - name: Credits
  - name: Customer Portal Sessions
  - name: Customers
  - name: Insights
  - name: Integrations
  - name: Invoices
  - name: Merchants
  - name: Payments
  - name: Plans
  - name: Product Bundles
  - name: Products
  - name: Refunds
  - name: Revenue Schedules
  - name: Subscription Changes
  - name: Subscription Versions
  - name: Subscriptions
  - name: Tax
  - name: Wallet Grants
  - name: Wallets
paths:
  /invoices/{id}/credit-notes:
    post:
      tags:
        - Credit Notes
      summary: Credit an invoice
      description: >-
        Creates a draft credit note against an invoice, crediting it at the
        prices and tax it was issued with rather than calculating tax again.
        Omit `line_items` to credit everything still uncredited on the invoice.
        Give `line_items` to credit specific invoice lines, each by the
        `quantity` of units to credit, which may be fractional. Every line here
        credits an invoice line item; to credit an amount that is not on the
        invoice, use create-credit-note instead.
      operationId: create-credit-note-from-invoice
      parameters:
        - in: header
          name: Alguna-Version
          required: true
          schema:
            enum:
              - '2026-04-01'
            type: string
        - in: header
          name: Idempotency-Key
          schema:
            description: >-
              A unique string used to ensure the request is processed exactly
              once. If you retry a request with the same idempotency key within
              24 hours, the original response is returned without re-executing
              the operation.
            example: ik_a1b2c3d4e5f6
            maxLength: 255
            type: string
        - in: path
          name: id
          required: true
          schema:
            description: Unique identifier for the invoice
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateCreditNoteFromInvoiceRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditNoteResponse'
          description: Success
          headers:
            Idempotency-Key:
              description: Echo of the idempotency key provided in the request
              schema:
                type: string
            Idempotent-Replayed:
              description: >-
                Whether this response was replayed from a previous request
                (true) or freshly executed (false)
              schema:
                type: boolean
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unauthorized
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Not Found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: >-
            Conflict — a request with this idempotency key is currently being
            processed
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal Server Error
components:
  schemas:
    CreateCreditNoteFromInvoiceRequest:
      properties:
        line_items:
          description: >-
            Invoice lines to credit and how many units of each. Omit to credit
            everything still uncredited on the invoice.
          items:
            $ref: '#/components/schemas/CreditInvoiceLineItemInput'
          type: array
      type: object
    CreditNoteResponse:
      properties:
        accounting_credit_note_id:
          description: Credit note ID in the accounting system
          nullable: true
          type: string
        accounting_credit_note_url:
          description: URL to the credit note in the accounting system
          nullable: true
          type: string
        accounting_integration_id:
          description: Accounting integration ID
          nullable: true
          type: string
        accounting_provider:
          description: Accounting provider name
          nullable: true
          type: string
        apply_date:
          description: Date the credit note was applied
          example: '2026-03-01T00:00:00Z'
          format: date-time
          nullable: true
          type: string
        attachments:
          description: Attachments on this credit note
          items:
            $ref: '#/components/schemas/CreditNoteAttachmentResponse'
          type: array
        billing_period_end:
          description: End of the billing period
          example: '2026-01-31T23:59:59Z'
          format: date-time
          nullable: true
          type: string
        billing_period_start:
          description: Start of the billing period
          example: '2026-01-01T00:00:00Z'
          format: date-time
          nullable: true
          type: string
        created_at:
          description: Timestamp when the credit note was created
          example: '2026-04-01T10:00:00Z'
          format: date-time
          type: string
        credit_date:
          description: Date of the credit
          example: '2026-03-01T00:00:00Z'
          format: date-time
          nullable: true
          type: string
        currency:
          description: Currency code
          example: USD
          type: string
        customer_id:
          description: Customer this credit note belongs to
          example: cust_01H1VECT
          type: string
        description:
          description: Description of the credit note
          example: Overcharge credit
          type: string
        external_reference:
          description: External reference identifier
          type: string
        id:
          description: Unique identifier for the credit note
          example: cn_01H1VECT
          type: string
        invoice_id:
          description: Associated invoice ID
          nullable: true
          type: string
        is_pdf_available:
          description: Whether a PDF is available for download
          type: boolean
        last_refund_date:
          description: Date of the last refund
          format: date-time
          nullable: true
          type: string
        last_refund_id:
          description: ID of the last refund
          nullable: true
          type: string
        legal_entity_id:
          description: Legal entity ID
          nullable: true
          type: string
        line_items:
          description: Line items on this credit note
          items:
            $ref: '#/components/schemas/CreditNoteLineItemResponse'
          type: array
        merchant_id:
          description: >-
            Sub-merchant the credited invoice was issued for; inherited from
            that invoice
          example: mrch_01H8XGJWBWBAQ4PLwXYZ
          nullable: true
          type: string
        purchase_order_number:
          description: Purchase order number
          nullable: true
          type: string
        status:
          description: Current status of the credit note
          enum:
            - draft
            - applied
            - void
            - pending_refund
          example: draft
          type: string
        subtotal:
          description: Subtotal before tax
          example: '100.00'
          type: string
        sync_enabled:
          description: Whether accounting sync is enabled
          type: boolean
        tax:
          description: Tax amount
          example: '10.00'
          type: string
        total:
          description: Total amount including tax
          example: '110.00'
          type: string
        updated_at:
          description: Timestamp when the credit note was last updated
          example: '2026-04-01T12:30:00Z'
          format: date-time
          type: string
        void_date:
          description: Date the credit note was voided
          format: date-time
          nullable: true
          type: string
      required:
        - attachments
        - created_at
        - currency
        - customer_id
        - description
        - external_reference
        - id
        - is_pdf_available
        - line_items
        - status
        - subtotal
        - sync_enabled
        - tax
        - total
        - updated_at
      type: object
    ErrorResponse:
      properties:
        detail:
          type: string
        status:
          format: int64
          type: integer
      required:
        - status
        - detail
      type: object
    CreditInvoiceLineItemInput:
      properties:
        invoice_line_item_id:
          description: Invoice line item to credit
          example: ili_01H1VECT
          type: string
        quantity:
          description: Units to credit, priced and taxed exactly as they were billed
          example: '2'
          type: string
      required:
        - invoice_line_item_id
        - quantity
      type: object
    CreditNoteAttachmentResponse:
      properties:
        file_url:
          description: URL to the attachment file
          type: string
        title:
          description: Title of the attachment
          example: Credit Note PDF
          type: string
      required:
        - file_url
        - title
      type: object
    CreditNoteLineItemResponse:
      properties:
        additional_description:
          description: Additional description for the line item
          nullable: true
          type: string
        billing_period_end:
          description: End of the billing period
          example: '2026-01-31T23:59:59Z'
          format: date-time
          type: string
        billing_period_start:
          description: Start of the billing period
          example: '2026-01-01T00:00:00Z'
          format: date-time
          type: string
        description:
          description: Description of the line item
          example: Platform usage credit
          type: string
        id:
          description: Unique identifier for the line item
          example: cnli_01H1VECT
          type: string
        invoice_line_item_id:
          description: Associated invoice line item ID
          nullable: true
          type: string
        is_editable:
          description: Whether the line item can be edited
          type: boolean
        product_id:
          description: Associated product ID
          example: prod_01H1VECT
          nullable: true
          type: string
        quantity:
          description: Quantity of items
          example: '1'
          type: string
        tax_amount:
          description: Tax amount for the line item
          example: '10.00'
          nullable: true
          type: string
        tax_rate:
          description: Tax rate applied to the line item
          example: '0.10'
          nullable: true
          type: string
        total_price:
          description: Total price of the line item
          example: '100.00'
          type: string
        unit_price:
          description: Unit price of the line item, excluding tax
          example: '100.00'
          type: string
      required:
        - billing_period_end
        - billing_period_start
        - description
        - id
        - is_editable
        - quantity
        - total_price
        - unit_price
      type: object
  securitySchemes:
    bearerAuth:
      bearerFormat: API Key
      description: API key authentication. Pass your API key as a Bearer token.
      scheme: bearer
      type: http

````