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

# Refund an invoice

> Refund a captured invoice in full or partially. Use when goods are returned or cancelled post-invoice. Reverses financing and adjusts merchant payouts.

When a buyer returns goods, cancels an order after invoicing, or disputes a charge, you refund the invoice to reverse the financing obligation. Tilta handles the refund differently depending on the timing: if the merchant payout has not yet been disbursed, it is cancelled or reduced by the refund amount; if payout has already occurred, the refund amount is reversed and offset against future merchant payouts. Partial refunds are supported – provide an `amount` smaller than the invoice total to refund only part of the financed value.

<Note>
  A full refund releases the entire financed amount back to the buyer's credit facility. A partial refund releases only the
  refunded portion, leaving the remaining balance active and due on the original `due_at` date.
</Note>

<Warning>
  Refunds cannot be undone. If you issue an incorrect refund, you must create a new order and invoice to re-finance the
  transaction.
</Warning>

<Tip>
  For partial shipment scenarios where only some items are returned, calculate the refund amount as the sum of the returned line
  items including tax, then submit that value in the `amount` field.
</Tip>


## OpenAPI

````yaml POST /v1/invoices/{external_id}/refund
openapi: 3.0.0
info:
  version: 0.0.1
  title: Tilta API
  description: Tilta API documentation
servers:
  - url: https://api.tilta.io
    description: Tilta Production API
  - url: https://api.tilta-sandbox.io
    description: Tilta Sandbox API
security: []
paths:
  /v1/invoices/{external_id}/refund:
    post:
      tags:
        - Invoices
      summary: Refund an invoice
      description: Refunds the invoice.
      parameters:
        - schema:
            type: string
            maxLength: 100
            pattern: ^[a-zA-Z0-9-_]+$
            description: Unique identifier of an invoice.
          required: true
          name: external_id
          in: path
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  paid_at:
                    type: number
                    description: >-
                      Unix timestamp in seconds for the banking update recorded
                      for this invoice.
                    example: 1712419200
                required:
                  - paid_at
                description: >-
                  The invoice was refunded; `paid_at` reflects the refund
                  timestamp.
        '400':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/badRequestSchema'
        '401':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/unauthorizedRequestSchema'
        '404':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/invoiceNotFoundSchema'
        '409':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/refundInvoiceConflictSchema'
      security:
        - bearerAuth: []
components:
  schemas:
    badRequestSchema:
      type: object
      properties:
        code:
          type: string
          description: Error code
          example: BAD_REQUEST
        error:
          type: string
          description: Error message for debugging purposes
          example: Request validation failed. 1 issue found.
        issues:
          type: array
          items:
            type: object
            properties:
              code:
                type: string
                description: Issue code
                example: INVALID_TYPE
              path:
                type: string
                description: Issue path starting with body, params, querystring, or headers
                example: body.registered_at
              message:
                type: string
                description: Issue message for debugging purposes
                example: Invalid type
            required:
              - code
              - path
              - message
          description: List of issues
          example:
            - code: INVALID_TYPE
              path: body.registered_at
              message: Invalid type
      required:
        - code
        - error
        - issues
      description: Bad Request, see error message for details.
      example:
        code: BAD_REQUEST
        error: Request validation failed. 1 issue found.
        issues:
          - code: INVALID_TYPE
            path: body.registered_at
            message: Invalid type
    unauthorizedRequestSchema:
      type: object
      properties:
        error:
          type: string
          description: Error details.
          example: Unauthorized
        code:
          type: string
          description: Error code.
          example: UNAUTHORIZED
      required:
        - error
        - code
      description: Unauthorized Request.
      example:
        error: Unauthorized
        code: UNAUTHORIZED
    invoiceNotFoundSchema:
      type: object
      properties:
        error:
          type: string
          description: Error details.
          example: No Entity found
        code:
          type: string
          description: Error code.
          example: NOT_FOUND
      required:
        - error
        - code
      description: No invoice found.
      example:
        error: No Entity found
        code: NOT_FOUND
    refundInvoiceConflictSchema:
      type: object
      properties:
        error:
          type: string
          description: Error details.
          example: Invoice is already marked as refunded.
        code:
          type: string
          description: Error code.
          example: CONFLICT
      required:
        - error
        - code
      description: Invoice is already marked as refunded.
      example:
        error: Invoice is already marked as refunded.
        code: CONFLICT
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Your Tilta API key, sent as `Bearer <key>`.

````