> ## 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.

# Preview a CFDI 4.0 invoice as an unstamped PDF

> Accepts the exact same request body as `POST /invoices`, runs the exact same catalog/CFDI 4.0 validations, but never timbra (no PAC call) and never persists anything — no invoice, no cuota consumida, no idempotencyKey handling. Returns a PDF clearly marked as 'VISTA PREVIA — NO VÁLIDO FISCALMENTE' so it can never be confused with a real representación impresa.



## OpenAPI

````yaml https://api.timbrix.mx/api/openapi.json post /invoices/preview/pdf
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/preview/pdf:
    post:
      tags:
        - invoices
      summary: Preview a CFDI 4.0 invoice as an unstamped PDF
      description: >-
        Accepts the exact same request body as `POST /invoices`, runs the exact
        same catalog/CFDI 4.0 validations, but never timbra (no PAC call) and
        never persists anything — no invoice, no cuota consumida, no
        idempotencyKey handling. Returns a PDF clearly marked as 'VISTA PREVIA —
        NO VÁLIDO FISCALMENTE' so it can never be confused with a real
        representación impresa.
      operationId: InvoicesController_previewPdf
      parameters:
        - name: X-Organization-Id
          in: header
          description: >-
            Required for Supabase session auth. Ignored when authenticating with
            an API key (the organization resolves from the key).
          required: false
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateInvoiceDto'
      responses:
        '200':
          description: PDF de vista previa del CFDI
        '400':
          description: >-
            Invalid invoice payload, or missing X-Organization-Id header for a
            session request
        '404':
          description: customerId not found
      security:
        - apiKey: []
        - bearer: []
components:
  schemas:
    CreateInvoiceDto:
      type: object
      properties:
        type:
          type: string
          example: I
          enum:
            - I
            - E
            - T
          description: 'Ingreso, Egreso, or Traslado (default: I)'
        relatedInvoiceUuid:
          type: string
          example: d3bfbc57-44af-4390-a064-f0afab85e5df
          description: >-
            Required when `type` is `E` (Egreso/nota de crédito) — UUID fiscal
            of the original Ingreso CFDI it credits. Must belong to this
            organization and be a vigente Ingreso.
        series:
          type: string
          example: A
        folioNumber:
          type: string
          example: '1'
        date:
          type: string
          example: '2026-07-30T22:50:00'
        paymentForm:
          type: string
          example: '01'
          description: >-
            SAT forma de pago catalog code — required unless `type` is `T`
            (Traslado)
        paymentMethod:
          type: string
          example: PUE
          enum:
            - PUE
            - PPD
          description: 'Default: PUE'
        currency:
          type: string
          example: MXN
          description: 'Default: MXN'
        exchange:
          type: number
          example: 1
          description: 'Default: 1'
        export:
          type: string
          example: '01'
          description: 'SAT clave de exportación catalog code — default: 01'
        use:
          type: string
          example: G03
          description: SAT uso CFDI catalog code
        customer:
          $ref: '#/components/schemas/InvoiceCustomerDto'
        customerId:
          type: string
          description: Existing customer ID — mutually exclusive with `customer`
        items:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceItemDto'
        idempotencyKey:
          type: string
          description: >-
            Client-supplied key to safely retry this request without
            double-stamping. If an invoice was already created for this
            organization with the same key, that invoice is returned instead of
            stamping again.
          example: order-8421-attempt-1
      required:
        - series
        - folioNumber
        - date
        - use
        - items
    InvoiceCustomerDto:
      type: object
      properties:
        legalName:
          type: string
          example: ESCUELA KEMPER URGATE SA DE CV
        taxId:
          type: string
          example: EKU9003173C9
        taxSystem:
          type: string
          example: '601'
          description: >-
            SAT régimen fiscal code — required unless the customer is público en
            general
        zip:
          type: string
          example: '45079'
      required:
        - legalName
        - taxId
    InvoiceItemDto:
      type: object
      properties:
        quantity:
          type: number
          example: 1
        productId:
          type: string
          description: >-
            Existing product/service ID — mutually exclusive with
            `productKey`/`unitKey`/`description`/`unitPrice` (inline concept
            data)
        description:
          type: string
          example: Servicio de consultoría
          description: Required unless `productId` is provided
        unitPrice:
          type: number
          example: 100
          description: Required unless `productId` is provided
        amount:
          type: number
          example: 100
        productKey:
          type: string
          example: '84111506'
          description: Required unless `productId` is provided
        unitKey:
          type: string
          example: E48
          description: Required unless `productId` is provided
        unit:
          type: string
          example: E48
        taxObject:
          type: string
          example: '02'
        taxes:
          type: array
          items:
            $ref: '#/components/schemas/InvoiceTaxDto'
      required:
        - quantity
        - amount
    InvoiceTaxDto:
      type: object
      properties:
        type:
          type: string
          example: '002'
        factorType:
          type: string
          example: Tasa
        rate:
          type: string
          example: '0.160000'
        base:
          type: number
          example: 100
        amount:
          type: number
          example: 16
        withholding:
          type: boolean
          description: >-
            true = retención (Impuestos.Retenciones), false/omitted = traslado
            (Impuestos.Traslados)
          example: false
      required:
        - type
        - factorType
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: 'API Key for authentication (format: sk_...)'
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http

````