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

# Cancel an invoice

> Cancel an invoice before the buyer funds it. 15-minute undo window — see ADR 0007.



## OpenAPI

````yaml https://api.caratuva.com/docs-json post /v1/invoices/{id}/cancel
openapi: 3.0.0
info:
  title: Caratuva API
  description: >-
    Cross-border B2B payments. Fiat on-ramp → USDC → PIX off-ramp.


    Every request runs in **test** or **live** mode on this single host — there
    is no separate sandbox URL. API keys carry the mode in their prefix
    (`pk_test_…` / `pk_live_…`); dashboard JWTs start in test and re-mint via
    `POST /v1/auth/switch-mode`. Test mode runs the full pipeline against a
    sandbox payment instance (KYB/KYC auto-approve, no real money); live runs on
    real rails and requires approved KYB. Test and live data are fully isolated.
    Check readiness with `GET /v1/onboarding/status`.
  version: 1.0.0
  contact: {}
servers: []
security: []
tags:
  - name: Invoices
    description: Create and manage invoices that collect for one of your sellers.
  - name: Payments
    description: Create a payment (keep your own checkout), fetch it, or cancel it.
  - name: Accounts
    description: >-
      Onboard and manage your sellers, buyers, and your own (self) account at
      the settlement partner.
  - name: Webhooks
    description: Subscribe to outbound event notifications and manage signing secrets.
  - name: API keys
    description: Issue, list, and revoke the API keys that authenticate your integration.
  - name: Access
    description: Request and check production (live-mode) access for your organization.
  - name: Reports
    description: Pull settlement and transfer-pricing reports.
paths:
  /v1/invoices/{id}/cancel:
    post:
      tags:
        - Invoices
      summary: Cancel an invoice
      description: >-
        Cancel an invoice before the buyer funds it. 15-minute undo window — see
        ADR 0007.
      operationId: InvoicesController_cancel
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                reason:
                  type: string
                  minLength: 1
                  maxLength: 500
              required:
                - reason
              additionalProperties: false
            examples:
              default:
                value:
                  reason: Buyer cancelled the purchase order.
      responses:
        '200':
          description: Invoice cancelled
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  publicId:
                    type: string
                  orgId:
                    type: string
                  buyerId:
                    type: string
                  buyerEmail:
                    type: string
                    format: email
                  buyerName:
                    type: string
                    nullable: true
                  sellerConnectedAccountId:
                    type: string
                  sellerExternalId:
                    type: string
                    nullable: true
                  sellerName:
                    type: string
                    nullable: true
                  status:
                    type: string
                    enum:
                      - draft
                      - awaiting_approval
                      - approved
                      - awaiting_buyer
                      - buyer_kyc_pending
                      - buyer_kyc_approved
                      - buyer_kyc_rejected
                      - fx_quoted
                      - fx_expired
                      - on_ramp_pending
                      - on_ramp_failed
                      - fiat_received
                      - on_chain_confirmed
                      - offramp_pending
                      - offramp_failed
                      - settled
                      - partial_payment
                      - expired
                      - cancelled
                      - restored
                      - manual_review
                  currency:
                    type: string
                  amount:
                    type: string
                  requestNetworkId:
                    type: string
                    nullable: true
                  paymentChain:
                    type: string
                    nullable: true
                  paymentAddress:
                    type: string
                    nullable: true
                  dueDate:
                    type: string
                    nullable: true
                  expiresAt:
                    type: string
                    nullable: true
                  cancelReason:
                    type: string
                    nullable: true
                  pendingApproval:
                    type: boolean
                  buyerRef:
                    type: string
                    nullable: true
                  dueNumber:
                    type: string
                    nullable: true
                  exportContractRef:
                    type: string
                    nullable: true
                  incoterm:
                    type: string
                    nullable: true
                  portOfLoading:
                    type: string
                    nullable: true
                  feeBps:
                    type: integer
                    nullable: true
                  feeAmount:
                    type: string
                    nullable: true
                  brlSettledAmount:
                    type: string
                    nullable: true
                  fxRateAtSettlement:
                    type: string
                    nullable: true
                  createdAt:
                    type: string
                  updatedAt:
                    type: string
                  lineItems:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        description:
                          type: string
                        quantity:
                          type: string
                        unitPrice:
                          type: string
                        subtotal:
                          type: string
                        ncmCode:
                          type: string
                          nullable: true
                        originState:
                          type: string
                          nullable: true
                      required:
                        - id
                        - description
                        - quantity
                        - unitPrice
                        - subtotal
                        - ncmCode
                        - originState
                      additionalProperties: false
                  timeline:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        invoiceId:
                          type: string
                        type:
                          type: string
                        source:
                          type: string
                        externalEventId:
                          type: string
                          nullable: true
                        occurredAt:
                          type: string
                      required:
                        - id
                        - invoiceId
                        - type
                        - source
                        - externalEventId
                        - occurredAt
                      additionalProperties: false
                required:
                  - id
                  - publicId
                  - orgId
                  - buyerId
                  - sellerConnectedAccountId
                  - sellerExternalId
                  - sellerName
                  - status
                  - currency
                  - amount
                  - requestNetworkId
                  - paymentChain
                  - paymentAddress
                  - dueDate
                  - expiresAt
                  - cancelReason
                  - pendingApproval
                  - buyerRef
                  - dueNumber
                  - exportContractRef
                  - incoterm
                  - portOfLoading
                  - feeBps
                  - feeAmount
                  - brlSettledAmount
                  - fxRateAtSettlement
                  - createdAt
                  - updatedAt
                  - timeline
                additionalProperties: false
              examples:
                default:
                  value:
                    id: ckxinv042
                    publicId: ckpub042
                    orgId: ckorg001
                    buyerId: ckbuy001
                    buyerEmail: buyer@acme.com
                    buyerName: ACME Imports LLC
                    sellerConnectedAccountId: ckacc042
                    sellerExternalId: seller-42
                    sellerName: Fazenda Boa Vista
                    status: cancelled
                    currency: USD
                    amount: '12500.00'
                    requestNetworkId: null
                    paymentChain: base
                    paymentAddress: 0x5fbe…a91c
                    dueDate: null
                    expiresAt: null
                    cancelReason: Buyer cancelled the purchase order.
                    pendingApproval: false
                    buyerRef: null
                    dueNumber: null
                    exportContractRef: null
                    incoterm: null
                    portOfLoading: null
                    feeBps: 50
                    feeAmount: '62.50'
                    brlSettledAmount: null
                    fxRateAtSettlement: null
                    createdAt: '2026-06-30T12:00:00.000Z'
                    updatedAt: '2026-06-30T12:00:00.000Z'
                    lineItems:
                      - id: ckli001
                        description: 'Order #42 — green coffee, 18t'
                        quantity: '1'
                        unitPrice: '12500.00'
                        subtotal: '12500.00'
                        ncmCode: null
                        originState: null
                    timeline:
                      - id: ckev001
                        invoiceId: ckxinv042
                        type: created
                        source: caratuva
                        externalEventId: null
                        occurredAt: '2026-06-30T12:00:00.000Z'
      security:
        - apiKey: []
        - bearer: []
components:
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http

````