Invoice Customization
You can add custom HTML using the pdf_custom_section field in the invoices request.
Allowed Tags
Tag | Allowed Attributes |
---|---|
h1 | — |
h2 | — |
h3 | — |
h4 | — |
h5 | — |
h6 | — |
div | — |
a | href , title , target , blank |
p | — |
span | — |
small | — |
br | — |
b | — |
i | — |
ul | — |
ol | — |
li | — |
strong | — |
table | — |
thead | — |
tbody | — |
tfoot | — |
tr | — |
th | colspan , align |
td | colspan , align |
Example
The following example shows how to send the pdf_custom_section
field in the invoice
creation request.
- Node.js
- C#
- PHP
- cURL
const Facturapi = require('facturapi');
const facturapi = new Facturapi('sk_test_API_KEY');
const invoice = await facturapi.invoices.create({
customer: {
legal_name: 'Dunder Mifflin',
email: 'email@example.com',
tax_id: 'ABC101010111',
tax_system: '601',
address: {
zip: '85900'
}
},
items: [{
quantity: 2,
product: {
description: 'Ukelele',
product_key: '60131324', // ClaveProdServ del SAT
price: 345.60,
taxes: [
{
type: 'IVA',
rate: 0.16
}
]
}
}],
use: 'G01',
payment_form: "28" // "Tarjeta de débito",
pdf_custom_section: '<h1>PDF Custom Section with h1</h1> <h2>Generado con <strong>Facturapi</strong></h2> <p>Detalles de la factura mediante tabla:</p> <table> <thead> <tr><th colspan="1" align="center">¡Concepto encerrado en thead!</th><th colspan="1" align="right">Importe</th></tr> </thead> <tbody> <tr><td><b>Servicio de Consultoría</b></td><td colspan="1" align="right" >$5,000.00</td></tr> </tbody> <tfoot> <tr><td align="left"><small>Total</small></td><td align="right"><strong>$5,000.00</strong></td></tr> </tfoot> </table> <p><i>Consulta y descarga tu CFDI en el siguiente enlace:</i></p> <a href="https://www.facturapi.io" target="_blank">Ver factura</a> <p><strong>Opciones de pago:</strong></p> <ul> <li>Transferencia bancaria</li> <li>Pago con tarjeta</li> </ul> <span><strong>Pasos para validar tu CFDI:</strong></span> <ol> <li>Accede al SAT</li> <li>Ingresa tu RFC y UUID</li> <li>Verifica la autenticidad</li> </ol> <br> <div>Si tienes dudas, contacta a soporte de <span>Facturapi</span>.</div>'
});
var facturapi = new FacturapiClient("sk_test_API_KEY");
var invoice = await facturapi.Invoice.CreateAsync(new Dictionary<string, object>
{
["customer"] = new Dictionary<string, object>
{
["legal_name"] = "Dunder Mifflin",
["email"] = "email@example.com",
["tax_id"] = "ABC101010111",
["tax_system"] = "601",
["address"] = new Dictionary<string, object>
{
["zip"] = "85900"
}
},
["items"] = new Dictionary<string, object>[]
{
new Dictionary<string, object>
{
["quantity"] = 2,
["product"] = new Dictionary<string, object>
{
["description"] = "Ukelele",
["product_key"] = "60131324", // ClaveProdServ del SAT
["price"] = 345.60,
["taxes"] = new Dictionary<string, object>[]
{
new Dictionary<string, object>
{
["type"] = "IVA",
["rate"] = 0.16
}
}
}
["product"] = new Dictionary<string, object>
{
["description"] = "Ukelele",
["product_key"] = "60131324", // ClaveProdServ del SAT
["price"] = 345.60,
["taxes"] = new Dictionary<string, object>[]
{
new Dictionary<string, object>
{
["type"] = "IVA",
["rate"] = 0.16
}
}
}
}
},
["use"] = "G01",
["payment_form"] = "28" // "Tarjeta de débito",
["pdf_custom_section"] = "<h1>PDF Custom Section with h1</h1> <h2>Generado con <strong>Facturapi</strong></h2> <p>Detalles de la factura mediante tabla:</p> <table> <thead> <tr><th colspan="1" align="center">¡Concepto encerrado en thead!</th><th colspan="1" align="right">Importe</th></tr> </thead> <tbody> <tr><td><b>Servicio de Consultoría</b></td><td colspan="1" align="right" >$5,000.00</td></tr> </tbody> <tfoot> <tr><td align="left"><small>Total</small></td><td align="right"><strong>$5,000.00</strong></td></tr> </tfoot> </table> <p><i>Consulta y descarga tu CFDI en el siguiente enlace:</i></p> <a href="https://www.facturapi.io" target="_blank">Ver factura</a> <p><strong>Opciones de pago:</strong></p> <ul> <li>Transferencia bancaria</li> <li>Pago con tarjeta</li> </ul> <span><strong>Pasos para validar tu CFDI:</strong></span> <ol> <li>Accede al SAT</li> <li>Ingresa tu RFC y UUID</li> <li>Verifica la autenticidad</li> </ol> <br> <div>Si tienes dudas, contacta a soporte de <span>Facturapi</span>.</div>"
});
$facturapi = new Facturapi( "sk_test_API_KEY" );
$invoice = $facturapi->Invoices->create([
"customer" => [
"legal_name" => "Dunder Mifflin",
"email" => "email@example.com",
"tax_id" => "ABC101010111",
"tax_system" => "601",
"address" => [
"zip" => "85900"
]
],
"items" => [
[
"quantity" => 2,
"product" => [
"description" => "Ukelele",
"product_key" => "60131324", // ClaveProdServ del SAT
"price" => 345.60,
"taxes" => [
[
"type" => "IVA",
"rate" => 0.16,
]
]
]
],
],
"payment_form" => "28" // "Tarjeta de débito"
"pdf_custom_section" => "<h1>PDF Custom Section with h1</h1> <h2>Generado con <strong>Facturapi</strong></h2> <p>Detalles de la factura mediante tabla:</p> <table> <thead> <tr><th colspan="1" align="center">¡Concepto encerrado en thead!</th><th colspan="1" align="right">Importe</th></tr> </thead> <tbody> <tr><td><b>Servicio de Consultoría</b></td><td colspan="1" align="right" >$5,000.00</td></tr> </tbody> <tfoot> <tr><td align="left"><small>Total</small></td><td align="right"><strong>$5,000.00</strong></td></tr> </tfoot> </table> <p><i>Consulta y descarga tu CFDI en el siguiente enlace:</i></p> <a href="https://www.facturapi.io" target="_blank">Ver factura</a> <p><strong>Opciones de pago:</strong></p> <ul> <li>Transferencia bancaria</li> <li>Pago con tarjeta</li> </ul> <span><strong>Pasos para validar tu CFDI:</strong></span> <ol> <li>Accede al SAT</li> <li>Ingresa tu RFC y UUID</li> <li>Verifica la autenticidad</li> </ol> <br> <div>Si tienes dudas, contacta a soporte de <span>Facturapi</span>.</div>"
]);
curl https://www.facturapi.io/v2/invoices \
-H "Authorization: Bearer sk_test_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"customer": {
"legal_name": "Dunder Mifflin",
"email": "email@example.com",
"tax_id": "ABC101010111",
"tax_system": "601",
"address": {
"zip": "85900"
}
},
"items": [{
"quantity": 2,
"product": {
"description": "Ukelele",
"product_key": "60131324", // ClaveProdServ del SAT
"price": 345.60,
"taxes": [
{
"type": "IVA",
"rate": 0.16
}
]
}
}],
"use": "G01",
"payment_form": "28" // "Tarjeta de débito",
"pdf_custom_section": "<h1>PDF Custom Section with h1</h1> <h2>Generado con <strong>Facturapi</strong></h2> <p>Detalles de la factura mediante tabla:</p> <table> <thead> <tr><th colspan="1" align="center">¡Concepto encerrado en thead!</th><th colspan="1" align="right">Importe</th></tr> </thead> <tbody> <tr><td><b>Servicio de Consultoría</b></td><td colspan="1" align="right" >$5,000.00</td></tr> </tbody> <tfoot> <tr><td align="left"><small>Total</small></td><td align="right"><strong>$5,000.00</strong></td></tr> </tfoot> </table> <p><i>Consulta y descarga tu CFDI en el siguiente enlace:</i></p> <a href="https://www.facturapi.io" target="_blank">Ver factura</a> <p><strong>Opciones de pago:</strong></p> <ul> <li>Transferencia bancaria</li> <li>Pago con tarjeta</li> </ul> <span><strong>Pasos para validar tu CFDI:</strong></span> <ol> <li>Accede al SAT</li> <li>Ingresa tu RFC y UUID</li> <li>Verifica la autenticidad</li> </ol> <br> <div>Si tienes dudas, contacta a soporte de <span>Facturapi</span>.</div>"
}'