On this page⌄
Getting started
Introduction
The API is REST. It accepts XML, JSON or ZIP and returns PDF, JSON or ZIP. It is included in every plan, the free plan too.
- CFDI 4.0 income, credit note, transfer, payment and payroll, with all their complements.
- Withholding and payment information CFDI 2.0.
- PDF with the SAT QR code, seals, original string and your style.
- Every conversion is kept in your history: 90 days on the free plan and 1 year on paid plans.
Each XML converted successfully uses one document from your plan, just like in the app. Rejected XML files are not charged. Downloading a PDF again from your history does not use documents either.
Quickstart
- 1Open the app, go to the API section and create a key. Copy it, it is only shown once.
- 2Store it in an environment variable and send your XML.
- 3Open factura.pdf. Done.
export OBPDF_API_KEY="obpdf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
curl -X POST "https://api.obpdf.mx/v1/conversions?fileName=factura.xml" \
-H "Authorization: Bearer $OBPDF_API_KEY" \
-H "Content-Type: application/xml" \
--data-binary @factura.xml \
-o factura.pdfAuthentication
Send your key in the Authorization header of every request, with the Bearer prefix. Keys start with obpdf_.
Authorization: Bearer obpdf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxTreat keys like a password: keep them in environment variables, never in browser code or in a repository. You can have up to 10 active keys and revoke them from the app at any time. A revoked key stops working immediately.
If the key is missing, invalid or revoked, the response is 401:
HTTP/1.1 401 Unauthorized
{
"success": false,
"error": { "code": "UNAUTHENTICATED", "message": "Invalid API key" }
}Conversions
Convert an XML
/v1/conversionsThe simplest way: send the XML as is in the body and get the PDF back. Ideal for scripts and for saving the file directly.
Headers: Authorization and Content-Type: application/xml (text/xml is also accepted).
| Name | Type | Required | Description |
|---|---|---|---|
style | string | No | Style ID or name. If you leave it out, it is chosen automatically. |
fileName | string | No | File name for your history. Defaults to cfdi.xml. |
curl -X POST "https://api.obpdf.mx/v1/conversions?style=Principal&fileName=factura.xml" \
-H "Authorization: Bearer $OBPDF_API_KEY" \
-H "Content-Type: application/xml" \
--data-binary @factura.xml \
-o factura.pdfReturns the PDF with the X-Conversion-Id (ID in your history) and X-Cfdi-Uuid (tax folio) headers. If something fails, it returns JSON with the error.
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Disposition: attachment; filename="factura.pdf"
X-Conversion-Id: 1842
X-Cfdi-Uuid: 0fb21b92-4514-440d-b00f-da0b06dadb1d
RateLimit-Limit: 120
RateLimit-Remaining: 119
%PDF-1.3 ...Convert with JSON
/v1/conversionsIf your system works with JSON, send the XML as text inside the body. The response includes the PDF in base64.
| Name | Type | Required | Description |
|---|---|---|---|
xml | string | Yes | The full XML content, up to 5 MB. |
fileName | string | No | File name. The PDF gets the same name with a .pdf extension. |
style | string | number | No | Style ID or name. |
curl -X POST "https://api.obpdf.mx/v1/conversions" \
-H "Authorization: Bearer $OBPDF_API_KEY" \
-H "Content-Type: application/json" \
-d "$(jq -n --rawfile xml factura.xml \
'{fileName: "factura.xml", style: "Principal", xml: $xml}')"{
"success": true,
"data": {
"id": 1842,
"uuid": "0fb21b92-4514-440d-b00f-da0b06dadb1d",
"fileName": "factura.pdf",
"pdf": "JVBERi0xLjMKJf////8KOSAwIG9iago8PAovVHlwZSAvRXh0R1N0YXRl..."
}
}List conversions
/v1/conversionsBrowse your history, the same one you see in the app. Only conversions that have not expired are returned.
| Name | Type | Required | Description |
|---|---|---|---|
page | number | No | Page, starting at 1. Defaults to 1. |
pageSize | number | No | Results per page, from 1 to 100. Defaults to 10. |
search | string | No | Searches UUID, file name, RFC, names and folio. |
sortBy | string | No | createdAt, fechaEmision or total. Newest first by default. |
sortOrder | string | No | asc or desc. |
filter[field][operator] | string | No | Fields: tipo, emisorRfc, receptorRfc (eq and contains operators), createdAt and fechaEmision (eq, gt, gte, lt, lte with a YYYY-MM-DD date). |
curl -G "https://api.obpdf.mx/v1/conversions" \
-H "Authorization: Bearer $OBPDF_API_KEY" \
--data-urlencode "pageSize=50" \
--data-urlencode "sortBy=fechaEmision" \
--data-urlencode "sortOrder=desc" \
--data-urlencode "filter[emisorRfc][eq]=EKU9003173C9" \
--data-urlencode "filter[createdAt][gte]=2026-10-01"{
"success": true,
"data": {
"rows": [
{
"id": 1842,
"fileName": "factura.xml",
"uuid": "0fb21b92-4514-440d-b00f-da0b06dadb1d",
"documento": "cfdi",
"tipo": "I",
"version": "4.0",
"serie": "A",
"folio": "001",
"emisorRfc": "EKU9003173C9",
"emisorNombre": "ESCUELA KEMPER URGATE",
"receptorRfc": "URE180429TM6",
"receptorNombre": "UNIVERSIDAD ROBOTICA ESPAÑOLA",
"total": "199.960000",
"moneda": "MXN",
"fechaEmision": "2026-10-29T16:36:57.000Z",
"complementos": [],
"styleID": 3,
"expiresAt": "2027-10-31T03:36:37.000Z",
"createdAt": "2026-10-31T03:36:37.000Z",
"updatedAt": "2026-10-31T03:36:37.000Z"
}
],
"count": 1,
"page": 1,
"pageSize": 50,
"totalPages": 1
}
}Download a PDF
/v1/conversions/{id}/pdfGenerates the PDF of a conversion in your history again, with the style it used. Does not use documents.
| Name | Type | Required | Description |
|---|---|---|---|
id | number | Yes | Conversion ID (X-Conversion-Id or id in the list). |
curl "https://api.obpdf.mx/v1/conversions/1842/pdf" \
-H "Authorization: Bearer $OBPDF_API_KEY" \
-o factura.pdfStatistics
/v1/statsThe same figures as Home in the app: conversions this month, last month, per day, per type, top issuers and the 5 most recent.
curl "https://api.obpdf.mx/v1/stats" \
-H "Authorization: Bearer $OBPDF_API_KEY"{
"success": true,
"data": {
"monthCount": 128,
"previousMonthCount": 96,
"totalCount": 1042,
"emisorCount": 3,
"daily": [{ "date": "2026-10-31", "count": 12 }],
"byType": [{ "tipo": "I", "count": 101 }],
"topEmisores": [
{ "rfc": "EKU9003173C9", "nombre": "ESCUELA KEMPER URGATE", "count": 87 }
],
"recent": []
}
}Styles
How the style is chosen
Create and edit styles in the app or with this API. One key works for all your RFCs. When converting, OBPDF picks the style in this order:
- The one you send in style, by ID or name (case insensitive). If it does not exist, the response is 400 styleNotFound and no document is used.
- The style linked to the issuer RFC of the XML.
- Your default style.
- OBPDF's base design, in black and white.
If you have more styles than your plan allows, only the oldest ones up to the limit are applied.
List styles
/v1/stylesLists your organization styles with their full design. Accepts page, pageSize and search. If active is false, the style is over your plan limit and is not applied.
curl "https://api.obpdf.mx/v1/styles" \
-H "Authorization: Bearer $OBPDF_API_KEY"{
"success": true,
"data": {
"rows": [
{
"id": 3,
"name": "Sucursal Norte",
"emisorRfc": "EKU9003173C9",
"isDefault": false,
"active": true,
"template": {
"version": 1,
"accentColor": "#2563EB",
"secondaryColor": "#2563EB",
"secondaryOpacity": 6,
"headerLayout": "band",
"tableStyle": "solid",
"logoImageID": null,
"blocks": [{ "id": "header", "type": "header" }]
},
"images": [],
"createdAt": "2026-10-31T03:36:37.000Z",
"updatedAt": "2026-10-31T03:36:37.000Z"
}
],
"count": 1,
"page": 1,
"pageSize": 10,
"totalPages": 1
}
}Create a style
/v1/stylesCreates a style with its design and blocks. Use the same key for all your RFCs: each style is linked to a different emisorRfc and is applied automatically to its XML files.
Your plan applies: logo and images from Basic, and custom blocks from Professional. If your plan does not include them, the default content is used.
{
"name": "Sucursal Norte",
"emisorRfc": "EKU9003173C9",
"isDefault": false,
"template": {
"accentColor": "#2563EB",
"secondaryColor": "#2563EB",
"secondaryOpacity": 6,
"textColor": "#111827",
"labelColor": "#64748B",
"borderColor": "#DBEAFE",
"corners": "round",
"headerLayout": "band",
"tableStyle": "solid",
"font": "sans",
"textSize": "normal",
"logoImageID": null,
"blocks": [
{ "id": "header", "type": "header" },
{ "id": "receiver", "type": "receiver" },
{ "id": "details", "type": "details" },
{ "id": "concepts", "type": "concepts" },
{ "id": "totals", "type": "totals" },
{
"id": "banco",
"type": "fields",
"title": "Datos bancarios",
"fields": [
{ "label": "CLABE", "value": "012180001234567890" },
{ "label": "Referencia", "value": "{folio}" }
]
},
{ "id": "complements", "type": "complements" },
{ "id": "fiscalStamp", "type": "fiscalStamp" },
{ "id": "legend", "type": "legend" }
]
}
}curl -X POST "https://api.obpdf.mx/v1/styles" \
-H "Authorization: Bearer $OBPDF_API_KEY" \
-H "Content-Type: application/json" \
-d @estilo.jsonTemplate
accentColor | Title and line color, in hexadecimal. |
secondaryColor, secondaryOpacity | Box background and its intensity from 0 to 100. |
textColor, labelColor | Text and label color. |
borderColor, showBorders | Border and line color, and whether boxes have a border. |
corners | square, soft or round. |
headerLayout | classic, band or centered. |
tableStyle | soft, solid, lines or striped. |
font, textSize | sans or serif, and small, normal or large. |
showAmountInWords | Show the amount in words. |
logoImageID | ID of the header image, or null. |
blocks | Ordered list of blocks. Their order is the PDF order. |
Template blocks
header, receiver, details, related, concepts, totals | CFDI sections. Once each, they can be removed. |
complements, fiscalStamp, legend | Required. They can be moved, and are added automatically if missing. |
notes | Text: title, text and align (left, center, right). |
fields | Data: title and fields, a list of { label, value }, up to 12. |
table | Table: title, columns (up to 6) and rows (up to 30). |
signatures | Signature lines: signatures, up to 3. |
image | Image: imageID and align. |
divider, spacer | Line, and space with size (small, medium, large). |
Text in notes, fields, table and signatures accepts variables in braces: {serie}, {folio}, {uuid}, {fecha}, {total}, {moneda}, {emisor}, {rfcEmisor}, {receptor}, {rfcReceptor}, {formaPago}, {metodoPago} and {condicionesPago}.
Update and delete
/v1/styles/{id}PUT replaces the whole style, so send all its fields. DELETE removes it along with its images.
curl -X PUT "https://api.obpdf.mx/v1/styles/3" \
-H "Authorization: Bearer $OBPDF_API_KEY" \
-H "Content-Type: application/json" \
-d @estilo.json
curl -X DELETE "https://api.obpdf.mx/v1/styles/3" \
-H "Authorization: Bearer $OBPDF_API_KEY"Images and logo
/v1/styles/{id}/imagesUpload PNG or JPG up to 2 MB in base64, up to 4 per style. Use the id you get back in logoImageID or in an image block.
curl -X POST "https://api.obpdf.mx/v1/styles/3/images" \
-H "Authorization: Bearer $OBPDF_API_KEY" \
-H "Content-Type: application/json" \
-d "$(jq -n --arg data "$(base64 -w0 logo.png)" \
'{name: "logo.png", data: $data}')"
curl -X DELETE "https://api.obpdf.mx/v1/styles/3/images/IMAGE_ID" \
-H "Authorization: Bearer $OBPDF_API_KEY"Preview
/v1/styles/previewRenders a sample CFDI with the design you send and returns the PDF in base64. Does not use documents. styleID is optional and lets you use that style images.
curl -X POST "https://api.obpdf.mx/v1/styles/preview" \
-H "Authorization: Bearer $OBPDF_API_KEY" \
-H "Content-Type: application/json" \
-d '{"styleID": 3, "template": {"accentColor": "#2563EB", "logoImageID": null, "blocks": []}}'Batches
Create a batch
/v1/batchesFor many XML files at once. Send a ZIP and OBPDF converts it in the background. The response comes back right away with the batch ID.
Headers: Authorization and Content-Type: application/zip. The ZIP can be up to 50 MB with up to 2,000 XML files, in folders or not.
| Name | Type | Required | Description |
|---|---|---|---|
style | string | No | Style name or ID for the whole batch. If you leave it out, each XML uses its issuer's style or the default one. |
curl -X POST "https://api.obpdf.mx/v1/batches?style=Principal" \
-H "Authorization: Bearer $OBPDF_API_KEY" \
-H "Content-Type: application/zip" \
--data-binary @facturas.zip{
"success": true,
"data": {
"id": 45,
"status": "queued",
"style": "Principal",
"total": 120,
"converted": 0,
"failed": 0,
"errors": [],
"completedAt": null,
"expiresAt": "2026-11-07T18:20:00.000Z",
"createdAt": "2026-10-31T18:20:00.000Z"
}
}Get a batch
/v1/batches/{id}Checks progress. status goes from queued to processing and ends in completed (or failed if the batch could not be processed). Poll every 5 seconds or more.
curl "https://api.obpdf.mx/v1/batches/45" \
-H "Authorization: Bearer $OBPDF_API_KEY"{
"success": true,
"data": {
"id": 45,
"status": "completed",
"style": "Principal",
"total": 120,
"converted": 118,
"failed": 2,
"errors": [
{ "fileName": "borrador.xml", "error": "notStamped" },
{ "fileName": "factura-2019.xml", "error": "unsupportedVersion" }
],
"completedAt": "2026-10-31T18:20:41.000Z",
"expiresAt": "2026-11-07T18:20:00.000Z",
"createdAt": "2026-10-31T18:20:00.000Z"
}
}XML files that could not be converted are listed in errors with the same error key as a single conversion. If you run out of documents halfway through, the rest are marked documentsExhausted.
Download a batch
/v1/batches/{id}/pdfWhen status is completed, downloads a ZIP with one PDF per converted XML. If the batch has not finished, it returns 400 batchNotReady. Batches are kept for 7 days. Each PDF is also saved in your history.
curl "https://api.obpdf.mx/v1/batches/45/pdf" \
-H "Authorization: Bearer $OBPDF_API_KEY" \
-o pdf.zipFull example
Upload the ZIP, wait until it finishes, download the PDFs and check the errors:
import { readFile, writeFile } from "node:fs/promises";
import { setTimeout as sleep } from "node:timers/promises";
const headers = { Authorization: `Bearer ${process.env.OBPDF_API_KEY}` };
const upload = await fetch("https://api.obpdf.mx/v1/batches?style=Principal", {
method: "POST",
headers: { ...headers, "Content-Type": "application/zip" },
body: await readFile("facturas.zip"),
});
let { data: batch } = await upload.json();
while (batch.status === "queued" || batch.status === "processing") {
await sleep(5000);
const status = await fetch(`https://api.obpdf.mx/v1/batches/${batch.id}`, { headers });
({ data: batch } = await status.json());
console.log(`${batch.converted + batch.failed}/${batch.total}`);
}
if (batch.status === "failed") throw new Error(`Batch ${batch.id} failed`);
const zip = await fetch(`https://api.obpdf.mx/v1/batches/${batch.id}/pdf`, { headers });
await writeFile("pdf.zip", Buffer.from(await zip.arrayBuffer()));
for (const { fileName, error } of batch.errors) {
console.warn(`${fileName}: ${error}`);
}Objects
Conversion
| Field | Description |
|---|---|
id | ID in your history. |
uuid | CFDI tax folio. |
documento | cfdi or retenciones. |
tipo | I income, E credit note, T transfer, P payment, N payroll, R withholdings. |
serie, folio | Document series and folio, if present. |
emisorRfc, emisorNombre, receptorRfc, receptorNombre | Issuer and receiver data. |
total, moneda | Total as text with 6 decimals and the CFDI currency. |
fechaEmision | Document date. |
complementos | Names of the complements it includes, such as Pagos or CartaPorte. |
styleID | Style used to generate it, or null. |
expiresAt | Date it is deleted from your history. |
Batch
| Field | Description |
|---|---|
status | queued, processing, completed or failed. |
total | XML files found in the ZIP. |
converted, failed | How many were converted and how many failed. |
errors | List of { fileName, error } for the failed ones. |
completedAt | When it finished. |
expiresAt | When the PDF ZIP is deleted. |
Errors
Every error response is JSON with success set to false. Use error.code for the kind of error and error.meta.key, when present, for the exact reason.
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "not-stamped",
"meta": { "key": "notStamped" }
}
}| HTTP | code | meta.key | Meaning |
|---|---|---|---|
| 400 | VALIDATION_ERROR | invalidXml | The file is not valid XML. |
| 400 | VALIDATION_ERROR | notCfdi | The XML is not a CFDI or a withholding CFDI. |
| 400 | VALIDATION_ERROR | unsupportedVersion | Not CFDI 4.0 or withholdings 2.0 (for example, a CFDI 3.3). |
| 400 | VALIDATION_ERROR | unsupportedType | Document type not supported. |
| 400 | VALIDATION_ERROR | notStamped | The CFDI has no digital tax stamp. |
| 400 | VALIDATION_ERROR | styleNotFound | The style you sent does not exist. |
| 400 | VALIDATION_ERROR | invalidZip, emptyZip, tooManyFiles | The ZIP is damaged, has no XML or has more than 2,000. |
| 400 | VALIDATION_ERROR | — | A parameter is invalid. Details are in message. |
| 400 | VALIDATION_ERROR | nameInUse, rfcInUse | You already have a style with that name or RFC. |
| 400 | ACTION_NOT_ALLOWED | styleLimit | You reached your plan style limit. |
| 400 | ACTION_NOT_ALLOWED | imagesNotInPlan, imageLimit | Your plan has no images or the style already has 4. |
| 400 | VALIDATION_ERROR | invalidImage, imageTooLarge | The image is not PNG or JPG, or is over 2 MB. |
| 400 | ACTION_NOT_ALLOWED | batchNotReady | The batch has not finished yet. |
| 400 | ACTION_NOT_ALLOWED | xmlNotStored | That conversion did not store its XML and cannot be generated again. |
| 401 | UNAUTHENTICATED | — | The key is missing, invalid or revoked. |
| 402 | DOCUMENTS_EXHAUSTED | — | You have no documents left. Buy more or change your plan. |
| 404 | NOT_FOUND | — | The conversion or batch does not exist. |
| 413 | PAYLOAD_TOO_LARGE | — | The XML is over 5 MB or the ZIP is over 50 MB. |
| 429 | RATE_LIMITED | — | You hit the request limit. Wait and retry. |
| 500 | INTERNAL_ERROR | — | An error on our side. Retry and, if it persists, contact us. |
Limits
- Requests
- 120 per minute per key. Every response includes RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset.
- XML
- Up to 5 MB per file.
- ZIP
- Up to 50 MB and 2,000 XML files per batch.
- Keys
- Up to 10 active per organization.
- History
- 90 days on the free plan and 1 year on paid plans.
- Batches
- The PDF ZIP is kept for 7 days.
- Documents
- Your plan's documents each month, plus the ones you buy, which do not expire.
Questions, or something not working as expected? Write to us at [email protected].