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

# Create refund (full or partial)

> Create a simple refund for an invoice. Provide partial_amount to create a partial refund.



## OpenAPI

````yaml POST /v1/platform/businesses/{business_id}/invoices/refunds/
openapi: 3.0.3
info:
  title: Thredfi Accounting Platform API
  version: 1.0.0
  description: >-
    Comprehensive API for accounting, invoice management, open banking, and
    intelligence services.
servers: []
security: []
paths:
  /v1/platform/businesses/{business_id}/invoices/refunds/:
    post:
      tags:
        - Refunds
      summary: Create refund (full or partial)
      description: >-
        Create a simple refund for an invoice. Provide partial_amount to create
        a partial refund.
      operationId: create_refund
      parameters:
        - in: path
          name: business_id
          schema:
            type: string
            format: uuid
          description: Business UUID provided by Thred (unique identifier for the business)
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSimpleRefundRequest'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/CreateSimpleRefundRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/CreateSimpleRefundRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Refund'
          description: ''
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
          description: Validation errors in request data
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Authentication required - missing or invalid API key
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Permission denied - insufficient privileges
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Resource not found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Conflict - resource already exists or invalid state transition
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unprocessable entity - business logic validation failed
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal server error
      security:
        - PartnerJWT: []
        - BusinessScopedJWT: []
        - BasicAuth: []
        - BearerUnscoped: []
        - BearerBusinessScoped: []
components:
  schemas:
    CreateSimpleRefundRequest:
      type: object
      description: Serializer for creating simple refunds
      properties:
        invoice_id:
          type: string
          format: uuid
          description: Invoice to refund
        method:
          enum:
            - CASH
            - CHECK
            - CREDIT_CARD
            - DEBIT_CARD
            - ACH
            - BANK_TRANSFER
            - PAYPAL
            - STRIPE
            - OTHER
          type: string
          x-spec-enum-id: c331bf4f48370b25
          description: |-
            Payment method for the refund

            * `CASH` - Cash
            * `CHECK` - Check
            * `CREDIT_CARD` - Credit Card
            * `DEBIT_CARD` - Debit Card
            * `ACH` - ACH
            * `BANK_TRANSFER` - Bank Transfer
            * `PAYPAL` - PayPal
            * `STRIPE` - Stripe
            * `OTHER` - Other
        completed_at:
          type: string
          format: date-time
          description: When the refund was completed
        amount_cents:
          type: integer
          minimum: 1
          description: >-
            Optional: Partial refund amount in cents. If not provided, refunds
            full amount.
        external_id:
          type: string
          minLength: 1
          description: Required external identifier for idempotency (unique per business)
          maxLength: 255
        memo:
          type: string
          minLength: 1
          description: Optional description
        reference_number:
          type: string
          minLength: 1
          description: Optional reference number
          maxLength: 100
        processor:
          type: string
          minLength: 1
          description: Payment processor (e.g., STRIPE)
          maxLength: 100
        refund_processing_fee_cents:
          type: integer
          minimum: 0
          default: 0
          description: Processing fee for the refund in cents
        document:
          allOf:
            - $ref: '#/components/schemas/RefundDocumentUploadRequest'
          writeOnly: true
      required:
        - completed_at
        - external_id
        - invoice_id
        - method
    Refund:
      type: object
      description: Serializer for refunds (simple response). All amounts in cents.
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
          description: Unique refund identifier
        external_id:
          type: string
          description: Your unique identifier for this refund (used for idempotency)
          maxLength: 255
        refunded_amount:
          type: integer
          description: Total refunded amount in cents
          readOnly: true
        status:
          enum:
            - pending
            - processing
            - paid
            - failed
            - cancelled
          type: string
          x-spec-enum-id: c671b6dd1cffeef4
          description: |-
            Refund status (pending, processing, paid, failed, cancelled)

            * `pending` - Pending
            * `processing` - Processing
            * `paid` - Paid
            * `failed` - Failed
            * `cancelled` - Cancelled
        completed_at:
          type: string
          format: date-time
          nullable: true
          description: Timestamp when refund was fully paid
        is_dedicated:
          type: boolean
          description: Whether this is a dedicated refund (true/false)
        memo:
          type: string
          description: Description or reason for the refund
        reference_number:
          type: string
          description: Reference number for tracking
          maxLength: 100
        metadata:
          description: Custom key-value pairs for additional context
        customer_id:
          type: string
          format: uuid
          readOnly: true
          description: UUID of the customer receiving the refund
        customer_name:
          type: string
          readOnly: true
          description: Customer display name
        allocations:
          type: array
          items:
            $ref: '#/components/schemas/RefundAllocation'
          readOnly: true
        refund_payments:
          type: array
          items:
            $ref: '#/components/schemas/RefundPayment'
          readOnly: true
        document:
          allOf:
            - $ref: '#/components/schemas/DocumentFileUrl'
          readOnly: true
          description: Latest document linked to this refund
        currency:
          enum:
            - EUR
            - GBP
            - USD
            - SEK
            - NOK
            - DKK
            - ISK
            - MYR
            - SGD
          type: string
          x-spec-enum-id: 7e6a70e4775b3009
          description: |-
            Three-letter ISO 4217 currency code (EUR, GBP, USD)

            * `EUR` - Euro
            * `GBP` - British Pound
            * `USD` - US Dollar
            * `SEK` - Swedish Krona
            * `NOK` - Norwegian Krone
            * `DKK` - Danish Krone
            * `ISK` - Icelandic Króna
            * `MYR` - Malaysian Ringgit
            * `SGD` - Singapore Dollar
        created_at:
          type: string
          format: date-time
          readOnly: true
          description: Refund creation timestamp
        updated_at:
          type: string
          format: date-time
          readOnly: true
          description: Last update timestamp
      required:
        - allocations
        - created_at
        - customer_id
        - customer_name
        - document
        - id
        - refund_payments
        - refunded_amount
        - updated_at
    ValidationErrorResponse:
      type: object
      description: Validation error response with field-specific errors
      properties:
        error_code:
          type: string
          description: Error code (e.g., 'validation_error')
        message:
          type: string
          nullable: true
          description: Human-readable error message
        detail:
          type: object
          additionalProperties: {}
          description: Contains field_errors and additional context
        request_id:
          type: string
          description: Request ID for tracing
      required:
        - detail
        - error_code
        - message
    ErrorResponse:
      type: object
      description: Standard error response format
      properties:
        error_code:
          type: string
          description: Error code for programmatic handling
        message:
          type: string
          nullable: true
          description: Human-readable error message
        detail:
          type: object
          additionalProperties: {}
          description: Additional error details including field_errors and debug info
        request_id:
          type: string
          description: Request ID for tracing
      required:
        - error_code
        - message
    RefundDocumentUploadRequest:
      type: object
      description: Refund specific document upload payload.
      properties:
        file:
          type: string
          format: binary
          writeOnly: true
        document_type:
          type: string
          default: refund
        upload_source:
          type: string
        metadata: {}
        tags: {}
    RefundAllocation:
      type: object
      description: Serializer for refund allocations. All amounts in cents.
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
          description: Unique allocation identifier
        allocation_type:
          enum:
            - invoice
            - payment
            - credit
            - line_item
          type: string
          x-spec-enum-id: 43480172e47a143a
          description: |-
            Type of allocation (invoice, line_item, etc.)

            * `invoice` - Invoice Refund
            * `payment` - Payment Refund
            * `credit` - Customer Credit
            * `line_item` - Line Item Refund
        amount:
          type: integer
          description: Allocation amount in cents
          readOnly: true
        invoice_id:
          type: string
          format: uuid
          description: Invoice ID if allocated to invoice
          readOnly: true
        invoice_number:
          type: string
          description: Invoice number if allocated to invoice
          readOnly: true
        invoice_outstanding_balance_cents:
          type: integer
          description: Invoice outstanding balance in cents if allocated to invoice
          readOnly: true
        target_description:
          type: string
          readOnly: true
        description:
          type: string
          description: Allocation description or notes
          maxLength: 500
        allocation_date:
          type: string
          format: date-time
          description: Date when allocation was made
      required:
        - allocation_type
        - amount
        - id
        - invoice_id
        - invoice_number
        - invoice_outstanding_balance_cents
        - target_description
    RefundPayment:
      type: object
      description: Serializer for refund payments. All amounts in cents.
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
          description: Unique refund payment identifier
        refund_id:
          type: string
          format: uuid
          readOnly: true
          description: ID of the refund this payment belongs to
        external_id:
          type: string
          description: Your unique identifier for idempotency (unique within refund)
          maxLength: 255
        refunded_amount:
          type: integer
          description: Refunded amount in cents
          readOnly: true
        refund_processing_fee:
          type: integer
          readOnly: true
          description: Processing fee in cents
        completed_at:
          type: string
          format: date-time
          nullable: true
          description: Date and time when refund payment was completed
        method:
          enum:
            - BANK_TRANSFER
            - CREDIT_CARD
            - DEBIT_CARD
            - ACH
            - CHECK
            - CASH
            - PAYPAL
            - STRIPE
            - OTHER
          type: string
          x-spec-enum-id: ba977578c39a8b5e
          description: >-
            Payment method used for refund (CASH, CHECK, CREDIT_CARD,
            BANK_TRANSFER, etc.)


            * `BANK_TRANSFER` - Bank Transfer

            * `CREDIT_CARD` - Credit Card

            * `DEBIT_CARD` - Debit Card

            * `ACH` - ACH/Direct Debit

            * `CHECK` - Check/Cheque

            * `CASH` - Cash

            * `PAYPAL` - PayPal

            * `STRIPE` - Stripe

            * `OTHER` - Other
        processor:
          type: string
          description: Payment processor used (e.g., Stripe, PayPal, manual)
          maxLength: 100
        transaction_tags:
          description: List of tags for categorization and reconciliation tracking
        memo:
          type: string
          description: Optional description or notes for this refund payment
        metadata:
          description: Custom key-value pairs for payment context
        reconciled_bank_transactions:
          type: array
          items:
            $ref: '#/components/schemas/EntityReconciliationDetail'
          readOnly: true
          description: Bank transactions this refund payment is reconciled to
        created_at:
          type: string
          format: date-time
          readOnly: true
          description: Timestamp when refund payment record was created
        updated_at:
          type: string
          format: date-time
          readOnly: true
          description: Timestamp when refund payment record was last updated
      required:
        - created_at
        - id
        - reconciled_bank_transactions
        - refund_id
        - refund_processing_fee
        - refunded_amount
        - updated_at
    DocumentFileUrl:
      type: object
      description: Serializer for document file URL with metadata.
      properties:
        url:
          type: string
          format: uri
          description: Presigned URL for document download
        expires_in:
          type: integer
          description: Seconds until URL expires
        document_id:
          type: string
          format: uuid
          description: Document UUID
        file_name:
          type: string
          description: Original document filename
        file_size:
          type: integer
          description: File size in bytes
        mime_type:
          type: string
          description: MIME type of the document
      required:
        - document_id
        - expires_in
        - file_name
        - file_size
        - mime_type
        - url
    EntityReconciliationDetail:
      type: object
      description: >-
        Which bank transaction an entity (invoice/bill payment) is reconciled
        to.
      properties:
        payment_type:
          type: string
        bank_transaction_id:
          type: string
          format: uuid
        bank_transaction_date:
          type: string
          format: date-time
        bank_transaction_amount_cents:
          type: integer
        bank_transaction_direction:
          type: string
        reconciled_amount_cents:
          type: integer
        reconciliation_link_id:
          type: string
          format: uuid
        reconciled_at:
          type: string
          format: date-time
        currency:
          type: string
        bank_account_name:
          type: string
        notes:
          type: string
      required:
        - bank_transaction_amount_cents
        - bank_transaction_date
        - bank_transaction_direction
        - bank_transaction_id
        - currency
        - reconciled_amount_cents
        - reconciled_at
        - reconciliation_link_id
  securitySchemes:
    PartnerJWT:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Partner-level JWT token (unscoped). Token payload includes `partner_id`.
        Business access is validated via partner ownership. Format: `Bearer
        <your-jwt-token>`


        **Use this for**: Multi-business operations where the business_id is
        specified in the URL and partner has access to multiple businesses.
    BusinessScopedJWT:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Business-scoped JWT token. Token payload includes `business_id` to
        automatically scope requests. Format: `Bearer <your-jwt-token>`


        **Use this for**: Business-specific operations where the business
        context is embedded in the token.
    BasicAuth:
      type: http
      scheme: basic
      description: >-
        Basic authentication for OAuth2 token endpoint. Use partner_uuid:api_key
        as username:password. Example: Authorization: Basic
        base64(partner_uuid:api_key)
    BearerUnscoped:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Partner (unscoped) JWT Bearer token. Obtain via POST
        /v1/platform/oauth2/token with Basic auth (partner_uuid:api_key). Use
        header: Authorization: Bearer {access_token}
    BearerBusinessScoped:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        Business-scoped JWT Bearer token. Obtain via POST
        /v1/platform/{business_id}/oauth2/token/ using a partner Bearer token.
        Only valid for endpoints whose URL contains that business_id.

````