Upload Invoice
curl --request POST \
--url https://api.example.com/api/invoices/upload \
--header 'Content-Type: application/json' \
--data '
{
"profileId": "<string>"
}
'{
"message": "<string>",
"data": {
"id": "<string>",
"profile_id": "<string>",
"uuid": "<string>",
"fecha": "<string>",
"mes": 123,
"año": 123,
"total": 123,
"subtotal": 123,
"iva": 123,
"iva_amount": 123,
"retencion_iva_amount": 123,
"retencion_isr_amount": 123,
"tipo": {},
"rfc_emisor": "<string>",
"nombre_emisor": "<string>",
"regimen_fiscal_emisor": "<string>",
"rfc_receptor": "<string>",
"nombre_receptor": "<string>",
"regimen_fiscal_receptor": "<string>",
"concepto": "<string>",
"pagos": [
{}
],
"complemento_pago": {},
"validacion": {},
"created_at": "<string>",
"updated_at": "<string>"
},
"validacion": {
"rfcVerificado": true,
"regimenFiscalVerificado": true,
"uuidDuplicado": true,
"advertencias": [
"<string>"
],
"errores": [
"<string>"
],
"valido": true
},
"tipo": {}
}Invoices
Upload Invoice
Upload a CFDI XML invoice file
POST
/
api
/
invoices
/
upload
Upload Invoice
curl --request POST \
--url https://api.example.com/api/invoices/upload \
--header 'Content-Type: application/json' \
--data '
{
"profileId": "<string>"
}
'{
"message": "<string>",
"data": {
"id": "<string>",
"profile_id": "<string>",
"uuid": "<string>",
"fecha": "<string>",
"mes": 123,
"año": 123,
"total": 123,
"subtotal": 123,
"iva": 123,
"iva_amount": 123,
"retencion_iva_amount": 123,
"retencion_isr_amount": 123,
"tipo": {},
"rfc_emisor": "<string>",
"nombre_emisor": "<string>",
"regimen_fiscal_emisor": "<string>",
"rfc_receptor": "<string>",
"nombre_receptor": "<string>",
"regimen_fiscal_receptor": "<string>",
"concepto": "<string>",
"pagos": [
{}
],
"complemento_pago": {},
"validacion": {},
"created_at": "<string>",
"updated_at": "<string>"
},
"validacion": {
"rfcVerificado": true,
"regimenFiscalVerificado": true,
"uuidDuplicado": true,
"advertencias": [
"<string>"
],
"errores": [
"<string>"
],
"valido": true
},
"tipo": {}
}Authentication
This endpoint requires authentication. Include your access token in the Authorization header.Authorization: Bearer YOUR_ACCESS_TOKEN
Request Body
This endpoint expects a multipart/form-data request with the following fields:XML file containing the CFDI invoice. The file must be a valid Mexican CFDI XML.
Profile ID to associate the invoice with. The system automatically determines if the invoice is an income (factura) or expense (gasto) based on the RFC in the XML.
Response
Success message
The created invoice object
Show Invoice
Show Invoice
Unique identifier for the invoice
Profile ID this invoice belongs to
CFDI UUID (Folio Fiscal)
Invoice date in ISO format
Month extracted from invoice date (1-12)
Year extracted from invoice date
Total amount of the invoice
Subtotal before taxes
IVA percentage rate
IVA transferred amount
IVA withholding amount
ISR withholding amount
Payment type:
PUE, PPD, or COMPLEMENTO_PAGORFC of the issuer
Name of the issuer
Tax regime code of the issuer
RFC of the recipient
Name of the recipient
Tax regime code of the recipient
Invoice concept or description
Array of payment records
Payment complement information (for COMPLEMENTO_PAGO type)
Validation results for the uploaded invoice
Creation timestamp in ISO format
Last update timestamp in ISO format
Validation state of the uploaded invoice
Show ValidationState
Show ValidationState
Whether RFC was verified against profile
Whether tax regime was verified
Whether this UUID already exists in the system
Array of warning messages that don’t prevent upload
Array of error messages (empty if valid)
Overall validation status
Classification of the invoice:
factura (income) or gasto (expense)Example Request
curl -X POST "https://api.contafy.com/api/invoices/upload" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-F "xml=@invoice.xml" \
-F "profileId=prof_123"
const formData = new FormData();
formData.append('xml', file);
formData.append('profileId', 'prof_123');
const response = await fetch('https://api.contafy.com/api/invoices/upload', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
},
body: formData
});
const data = await response.json();
Example Response
{
"message": "Factura procesada exitosamente",
"data": {
"id": "inv_abc123",
"profile_id": "prof_123",
"uuid": "12345678-90AB-CDEF-1234-567890ABCDEF",
"fecha": "2026-03-15T10:30:00Z",
"mes": 3,
"año": 2026,
"total": 11600.00,
"subtotal": 10000.00,
"iva": 16,
"iva_amount": 1600.00,
"tipo": "PUE",
"rfc_emisor": "XAXX010101000",
"nombre_emisor": "Empresa Ejemplo SA de CV",
"regimen_fiscal_emisor": "601",
"rfc_receptor": "BAXX010101000",
"nombre_receptor": "Cliente Ejemplo",
"regimen_fiscal_receptor": "612",
"concepto": "Servicios de consultoría",
"pagos": [],
"complemento_pago": null,
"validacion": {
"rfcVerificado": true,
"regimenFiscalVerificado": true,
"uuidDuplicado": false,
"advertencias": [],
"errores": [],
"valido": true
},
"created_at": "2026-03-15T10:35:00Z",
"updated_at": "2026-03-15T10:35:00Z"
},
"validacion": {
"rfcVerificado": true,
"regimenFiscalVerificado": true,
"uuidDuplicado": false,
"advertencias": [],
"errores": [],
"valido": true
},
"tipo": "factura"
}
Error Responses
401 Unauthorized
{
"error": "Unauthorized",
"message": "Invalid or missing access token"
}
400 Bad Request
{
"error": "Bad Request",
"message": "Invalid XML file or missing required fields"
}
409 Conflict
{
"error": "Conflict",
"message": "Invoice with this UUID already exists",
"validacion": {
"uuidDuplicado": true,
"valido": false
}
}
422 Unprocessable Entity
{
"error": "Unprocessable Entity",
"message": "Invalid CFDI XML format",
"validacion": {
"errores": ["Invalid XML structure"],
"valido": false
}
}
500 Internal Server Error
{
"error": "Internal Server Error",
"message": "An unexpected error occurred"
}
⌘I