create_invoice
Issue a Mexico CFDI 4.0 electronic invoice (factura electrónica, stamped/timbrada through a SAT-certified PAC). Two interchangeable PACs behind one tool (bring your own credentials as HTTP headers; this server stores nothing, and the CSD certificate stays in the merchant's own PAC account): (A) FACTURAPI — header x-facturapi-key (free sk_test_ from facturapi.io never reaches SAT; sk_live_ stamps real CFDIs). (B) FACTURAMA API-Web — headers x-facturama-user + x-facturama-password (your Facturama login) plus x-facturama-expedition-place (your branch-office 5-digit ZIP, which Facturama requires for the issuer); add x-facturama-sandbox: true for the no-fiscal-effect sandbox. Routing: whichever credential headers you send picks the PAC; if both are present Facturapi wins unless you set header x-invoice-provider: facturama. Sensible SAT defaults: product_key 01010101 (generic), payment_form 03 (bank transfer), use G03 (general expenses); item price is tax-inclusive (16% IVA assumed). For a buyer without RFC use tax_id XAXX010101000 with tax_system 616 and use S01.
Parameters8
| customer_legal_name | string | required | Buyer legal name (razón social) exactly as registered with SAT — must match the RFC or SAT rejects the stamp. |
| customer_tax_id | string | required | Buyer RFC, e.g. ABC680524P76. Generic consumer: XAXX010101000. |
| customer_zip | string | required | Buyer tax-address ZIP code (código postal fiscal), 5 digits — CFDI 4.0 requires it to match SAT records. |
| customer_tax_system | string | optional | Buyer régimen fiscal SAT code. Default 601 (General de Ley Personas Morales). Use 616 for the generic consumer RFC. |
| customer_email | string | optional | Optional buyer email — stored on the invoice so send_invoice can deliver the PDF+XML. |
| items | array | required | Line items. Each: description, price (MXN, tax-inclusive by default), optional quantity (default 1) and product_key (SAT catalog code, default 01010101). |
| payment_form | string | optional | SAT forma de pago code. Default 03 (transferencia). Common: 01 cash, 04 credit card, 28 debit card, 99 por definir. |
| use | string | optional | SAT uso del CFDI code. Default G03 (gastos en general). Use S01 with the generic RFC. |
Raw schema
{
"type": "object",
"properties": {
"customer_legal_name": {
"type": "string",
"description": "Buyer legal name (razón social) exactly as registered with SAT — must match the RFC or SAT rejects the stamp."
},
"customer_tax_id": {
"type": "string",
"description": "Buyer RFC, e.g. ABC680524P76. Generic consumer: XAXX010101000."
},
"customer_zip": {
"type": "string",
"description": "Buyer tax-address ZIP code (código postal fiscal), 5 digits — CFDI 4.0 requires it to match SAT records."
},
"customer_tax_system": {
"type": "string",
"description": "Buyer régimen fiscal SAT code. Default 601 (General de Ley Personas Morales). Use 616 for the generic consumer RFC."
},
"customer_email": {
"type": "string",
"description": "Optional buyer email — stored on the invoice so send_invoice can deliver the PDF+XML."
},
"items": {
"type": "array",
"minItems": 1,
"description": "Line items. Each: description, price (MXN, tax-inclusive by default), optional quantity (default 1) and product_key (SAT catalog code, default 01010101).",
"items": {
"type": "object",
"properties": {
"description": {
"type": "string"
},
"price": {
"type": "number",
"description": "Unit price in MXN."
},
"quantity": {
"type": "number",
"description": "Default 1."
},
"product_key": {
"type": "string",
"description": "SAT product/service catalog code. Default 01010101 (no specific code)."
}
},
"required": [
"description",
"price"
]
}
},
"payment_form": {
"type": "string",
"description": "SAT forma de pago code. Default 03 (transferencia). Common: 01 cash, 04 credit card, 28 debit card, 99 por definir."
},
"use": {
"type": "string",
"description": "SAT uso del CFDI code. Default G03 (gastos en general). Use S01 with the generic RFC."
}
},
"required": [
"customer_legal_name",
"customer_tax_id",
"customer_zip",
"items"
]
}