Overview
Create an invoice (factura) from a receipt image. The system will process the image, extract the relevant information, and generate a CFDI-compliant invoice.
This operation requires 1 credit. Make sure you have sufficient credits before calling this endpoint.
Request Body
Imagen del ticket codificada en Base64. Formatos soportados: JPEG, PNG.
Código de uso CFDI. Valores comunes:
G01 - Adquisición de mercancías
G02 - Devoluciones, descuentos o bonificaciones
G03 - Gastos en general
P01 - Por definir
Descripción opcional del gasto. Ejemplo: Comida de negocios
Response
Unique invoice identifier
Invoice status. Values: pending, processing, completed, failed
Invoice total amount (extracted from receipt)
Currency code (e.g., MXN)
Vendor name (extracted from receipt)
ISO 8601 timestamp of creation
URL to download the invoice PDF (available when status is completed)
URL to download the invoice XML/CFDI (available when status is completed)
curl -X POST "https://api.usatimbre.com/api/timbre/facturar-ticket" \
-H "Authorization: Bearer tmb_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"receipt_image": "data:image/jpeg;base64,/9j/4AAQSkZJRg...",
"cfdi_usage": "G03",
"expense_description": "Comida de negocios"
}'
{
"id": "inv_abc123",
"status": "processing",
"amount": null,
"currency": "MXN",
"vendor": null,
"created_at": "2024-01-21T10:30:00Z",
"pdf_url": null,
"xml_url": null
}
Processing Status
After creating an invoice, the status will be processing. You can poll the Get Invoice Details endpoint to check when processing is complete.
| Status | Description |
|---|
pending | Invoice request received |
processing | Receipt is being processed |
completed | Invoice generated successfully |
failed | Invoice generation failed |