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"
}'
const response = await fetch('https://api.usatimbre.com/api/timbre/facturar-ticket', {
method: 'POST',
headers: {
'Authorization': 'Bearer tmb_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
receipt_image: 'data:image/jpeg;base64,/9j/4AAQSkZJRg...',
cfdi_usage: 'G03',
expense_description: 'Comida de negocios'
})
});
const invoice = await response.json();
import requests
import base64
# Read and encode image
with open('receipt.jpg', 'rb') as f:
image_base64 = base64.b64encode(f.read()).decode('utf-8')
response = requests.post(
'https://api.usatimbre.com/api/timbre/facturar-ticket',
headers={
'Authorization': 'Bearer tmb_your_api_key_here',
'Content-Type': 'application/json'
},
json={
'receipt_image': f'data:image/jpeg;base64,{image_base64}',
'cfdi_usage': 'G03',
'expense_description': 'Comida de negocios'
}
)
invoice = response.json()
{
"id": "inv_abc123",
"status": "processing",
"amount": null,
"currency": "MXN",
"vendor": null,
"created_at": "2024-01-21T10:30:00Z",
"pdf_url": null,
"xml_url": null
}
{
"error": "Bad Request",
"message": "Invalid image format"
}
{
"error": "Payment Required",
"message": "Insufficient credits"
}
API Timbre (Facturas)
Create Invoice from Ticket
Create invoice from receipt image
POST
/
api
/
timbre
/
facturar-ticket
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"
}'
const response = await fetch('https://api.usatimbre.com/api/timbre/facturar-ticket', {
method: 'POST',
headers: {
'Authorization': 'Bearer tmb_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
receipt_image: 'data:image/jpeg;base64,/9j/4AAQSkZJRg...',
cfdi_usage: 'G03',
expense_description: 'Comida de negocios'
})
});
const invoice = await response.json();
import requests
import base64
# Read and encode image
with open('receipt.jpg', 'rb') as f:
image_base64 = base64.b64encode(f.read()).decode('utf-8')
response = requests.post(
'https://api.usatimbre.com/api/timbre/facturar-ticket',
headers={
'Authorization': 'Bearer tmb_your_api_key_here',
'Content-Type': 'application/json'
},
json={
'receipt_image': f'data:image/jpeg;base64,{image_base64}',
'cfdi_usage': 'G03',
'expense_description': 'Comida de negocios'
}
)
invoice = response.json()
{
"id": "inv_abc123",
"status": "processing",
"amount": null,
"currency": "MXN",
"vendor": null,
"created_at": "2024-01-21T10:30:00Z",
"pdf_url": null,
"xml_url": null
}
{
"error": "Bad Request",
"message": "Invalid image format"
}
{
"error": "Payment Required",
"message": "Insufficient credits"
}
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
string
required
Imagen del ticket codificada en Base64. Formatos soportados: JPEG, PNG.
string
required
Código de uso CFDI. Valores comunes:
G01- Adquisición de mercancíasG02- Devoluciones, descuentos o bonificacionesG03- Gastos en generalP01- Por definir
string
Descripción opcional del gasto. Ejemplo:
Comida de negociosResponse
string
Unique invoice identifier
string
Invoice status. Values:
pending, processing, completed, failednumber
Invoice total amount (extracted from receipt)
string
Currency code (e.g.,
MXN)string
Vendor name (extracted from receipt)
string
ISO 8601 timestamp of creation
string
URL to download the invoice PDF (available when status is
completed)string
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"
}'
const response = await fetch('https://api.usatimbre.com/api/timbre/facturar-ticket', {
method: 'POST',
headers: {
'Authorization': 'Bearer tmb_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
receipt_image: 'data:image/jpeg;base64,/9j/4AAQSkZJRg...',
cfdi_usage: 'G03',
expense_description: 'Comida de negocios'
})
});
const invoice = await response.json();
import requests
import base64
# Read and encode image
with open('receipt.jpg', 'rb') as f:
image_base64 = base64.b64encode(f.read()).decode('utf-8')
response = requests.post(
'https://api.usatimbre.com/api/timbre/facturar-ticket',
headers={
'Authorization': 'Bearer tmb_your_api_key_here',
'Content-Type': 'application/json'
},
json={
'receipt_image': f'data:image/jpeg;base64,{image_base64}',
'cfdi_usage': 'G03',
'expense_description': 'Comida de negocios'
}
)
invoice = response.json()
{
"id": "inv_abc123",
"status": "processing",
"amount": null,
"currency": "MXN",
"vendor": null,
"created_at": "2024-01-21T10:30:00Z",
"pdf_url": null,
"xml_url": null
}
{
"error": "Bad Request",
"message": "Invalid image format"
}
{
"error": "Payment Required",
"message": "Insufficient credits"
}
Processing Status
After creating an invoice, the status will beprocessing. 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 |