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

# Request cancellation of a stamped CFDI

> Authenticate with either a Supabase session (member of the invoice's organization) or an API key belonging to that same organization. Determines automatically whether the cancellation is direct or requires receptor approval per SAT rules — Timbrix cannot confirm receptor approval in real time, so a pending cancellation must be resolved manually via the resolve endpoint.



## OpenAPI

````yaml https://api.timbrix.mx/api/openapi.json post /invoices/{uuid}/cancel
openapi: 3.0.0
info:
  title: Timbrix API
  description: >-
    API de facturación electrónica CFDI 4.0 para México, con servidor OAuth2
    para gestionar organizaciones, miembros y webhooks. Compatible con agentes
    de IA — ver la extensión `x-ai-agent-friendly` en la raíz de esta spec.


    REST API with OAuth2 server for managing organizations, members, and
    webhooks.
  version: '1.0'
  contact: {}
servers: []
security: []
tags:
  - name: organizations
    description: Organization management endpoints
  - name: oauth
    description: OAuth2 authentication and authorization
  - name: webhooks
    description: Webhook configuration and delivery
  - name: users
    description: User information endpoints
  - name: api-keys
    description: API Keys management and validation
paths:
  /invoices/{uuid}/cancel:
    post:
      tags:
        - invoices
      summary: Request cancellation of a stamped CFDI
      description: >-
        Authenticate with either a Supabase session (member of the invoice's
        organization) or an API key belonging to that same organization.
        Determines automatically whether the cancellation is direct or requires
        receptor approval per SAT rules — Timbrix cannot confirm receptor
        approval in real time, so a pending cancellation must be resolved
        manually via the resolve endpoint.
      operationId: InvoicesController_cancel
      parameters:
        - name: uuid
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelInvoiceDto'
      responses:
        '201':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoiceCancellationDto'
        '400':
          description: >-
            Invalid motivo/folioSustitucion, invoice already cancelled, or
            mass-cancellation limit reached
        '403':
          description: Caller does not belong to the invoice's organization
        '404':
          description: uuid does not match any invoice
        '409':
          description: A cancellation is already pending for this invoice
      security:
        - apiKey: []
        - bearer: []
components:
  schemas:
    CancelInvoiceDto:
      type: object
      properties:
        motivo:
          type: string
          example: '02'
          enum:
            - '01'
            - '02'
            - '03'
            - '04'
          description: >-
            01 = emitido con errores con relación (requiere folioSustitucion),
            02 = emitido con errores sin relación, 03 = no se llevó a cabo la
            operación, 04 = operación nominativa relacionada en factura global
        folioSustitucion:
          type: string
          example: d3bfbc57-44af-4390-a064-f0afab85e5df
          description: >-
            UUID fiscal del CFDI que sustituye a este. Requerido cuando
            motivo=01, debe ser una factura vigente de la misma organización.
      required:
        - motivo
    InvoiceCancellationDto:
      type: object
      properties:
        id:
          type: string
        invoiceId:
          type: string
        motivo:
          type: string
          enum:
            - '01'
            - '02'
            - '03'
            - '04'
        folioSustitucion:
          type: object
        requiresApproval:
          type: boolean
        respondBy:
          type: object
        cancellationStatus:
          type: string
          enum:
            - pendiente
            - aceptada
            - rechazada
        requestedBy:
          type: object
        resolvedBy:
          type: object
        resolvedAt:
          type: object
        createdAt:
          format: date-time
          type: string
      required:
        - id
        - invoiceId
        - motivo
        - requiresApproval
        - cancellationStatus
        - createdAt
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: 'API Key for authentication (format: sk_...)'
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http

````