OBDocumentation

Documentation

OBPDF API

Convert stamped CFDI from XML to PDF from your ERP, your invoicing system or a script. The API uses the same styles, history and documents as the app.

Create a key
Base URLhttps://api.obpdf.mx/v1
On this page⌄

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

  1. 1Open the app, go to the API section and create a key. Copy it, it is only shown once.
  2. 2Store it in an environment variable and send your XML.
  3. 3Open factura.pdf. Done.
cURL
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.pdf

Authentication

Send your key in the Authorization header of every request, with the Bearer prefix. Keys start with obpdf_.

HTTP
Authorization: Bearer obpdf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Treat 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:

Response
HTTP/1.1 401 Unauthorized

{
  "success": false,
  "error": { "code": "UNAUTHENTICATED", "message": "Invalid API key" }
}

Conversions

Convert an XML

POST/v1/conversions

The 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).

NameTypeRequiredDescription
stylestringNoStyle ID or name. If you leave it out, it is chosen automatically.
fileNamestringNoFile 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.pdf

Returns 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.

Response
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

POST/v1/conversions

If your system works with JSON, send the XML as text inside the body. The response includes the PDF in base64.

NameTypeRequiredDescription
xmlstringYesThe full XML content, up to 5 MB.
fileNamestringNoFile name. The PDF gets the same name with a .pdf extension.
stylestring | numberNoStyle 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}')"
Response
{
  "success": true,
  "data": {
    "id": 1842,
    "uuid": "0fb21b92-4514-440d-b00f-da0b06dadb1d",
    "fileName": "factura.pdf",
    "pdf": "JVBERi0xLjMKJf////8KOSAwIG9iago8PAovVHlwZSAvRXh0R1N0YXRl..."
  }
}

List conversions

GET/v1/conversions

Browse your history, the same one you see in the app. Only conversions that have not expired are returned.

NameTypeRequiredDescription
pagenumberNoPage, starting at 1. Defaults to 1.
pageSizenumberNoResults per page, from 1 to 100. Defaults to 10.
searchstringNoSearches UUID, file name, RFC, names and folio.
sortBystringNocreatedAt, fechaEmision or total. Newest first by default.
sortOrderstringNoasc or desc.
filter[field][operator]stringNoFields: 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"
Response
{
  "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

GET/v1/conversions/{id}/pdf

Generates the PDF of a conversion in your history again, with the style it used. Does not use documents.

NameTypeRequiredDescription
idnumberYesConversion 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.pdf

Statistics

GET/v1/stats

The same figures as Home in the app: conversions this month, last month, per day, per type, top issuers and the 5 most recent.

cURL
curl "https://api.obpdf.mx/v1/stats" \
  -H "Authorization: Bearer $OBPDF_API_KEY"
Response
{
  "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:

  1. 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.
  2. The style linked to the issuer RFC of the XML.
  3. Your default style.
  4. 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

GET/v1/styles

Lists 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"
Response
{
  "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

POST/v1/styles

Creates 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.

estilo.json
{
  "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.json

Template

accentColorTitle and line color, in hexadecimal.
secondaryColor, secondaryOpacityBox background and its intensity from 0 to 100.
textColor, labelColorText and label color.
borderColor, showBordersBorder and line color, and whether boxes have a border.
cornerssquare, soft or round.
headerLayoutclassic, band or centered.
tableStylesoft, solid, lines or striped.
font, textSizesans or serif, and small, normal or large.
showAmountInWordsShow the amount in words.
logoImageIDID of the header image, or null.
blocksOrdered list of blocks. Their order is the PDF order.

Template blocks

header, receiver, details, related, concepts, totalsCFDI sections. Once each, they can be removed.
complements, fiscalStamp, legendRequired. They can be moved, and are added automatically if missing.
notesText: title, text and align (left, center, right).
fieldsData: title and fields, a list of { label, value }, up to 12.
tableTable: title, columns (up to 6) and rows (up to 30).
signaturesSignature lines: signatures, up to 3.
imageImage: imageID and align.
divider, spacerLine, 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

PUT/v1/styles/{id}

PUT replaces the whole style, so send all its fields. DELETE removes it along with its images.

cURL
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

POST/v1/styles/{id}/images

Upload 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
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

POST/v1/styles/preview

Renders 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
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

POST/v1/batches

For 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.

NameTypeRequiredDescription
stylestringNoStyle 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
Response
{
  "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

GET/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
curl "https://api.obpdf.mx/v1/batches/45" \
  -H "Authorization: Bearer $OBPDF_API_KEY"
Response
{
  "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

GET/v1/batches/{id}/pdf

When 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
curl "https://api.obpdf.mx/v1/batches/45/pdf" \
  -H "Authorization: Bearer $OBPDF_API_KEY" \
  -o pdf.zip

Full 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

FieldDescription
idID in your history.
uuidCFDI tax folio.
documentocfdi or retenciones.
tipoI income, E credit note, T transfer, P payment, N payroll, R withholdings.
serie, folioDocument series and folio, if present.
emisorRfc, emisorNombre, receptorRfc, receptorNombreIssuer and receiver data.
total, monedaTotal as text with 6 decimals and the CFDI currency.
fechaEmisionDocument date.
complementosNames of the complements it includes, such as Pagos or CartaPorte.
styleIDStyle used to generate it, or null.
expiresAtDate it is deleted from your history.

Batch

FieldDescription
statusqueued, processing, completed or failed.
totalXML files found in the ZIP.
converted, failedHow many were converted and how many failed.
errorsList of { fileName, error } for the failed ones.
completedAtWhen it finished.
expiresAtWhen 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.

Response
{
  "success": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "not-stamped",
    "meta": { "key": "notStamped" }
  }
}
HTTPcodemeta.keyMeaning
400VALIDATION_ERRORinvalidXmlThe file is not valid XML.
400VALIDATION_ERRORnotCfdiThe XML is not a CFDI or a withholding CFDI.
400VALIDATION_ERRORunsupportedVersionNot CFDI 4.0 or withholdings 2.0 (for example, a CFDI 3.3).
400VALIDATION_ERRORunsupportedTypeDocument type not supported.
400VALIDATION_ERRORnotStampedThe CFDI has no digital tax stamp.
400VALIDATION_ERRORstyleNotFoundThe style you sent does not exist.
400VALIDATION_ERRORinvalidZip, emptyZip, tooManyFilesThe ZIP is damaged, has no XML or has more than 2,000.
400VALIDATION_ERROR—A parameter is invalid. Details are in message.
400VALIDATION_ERRORnameInUse, rfcInUseYou already have a style with that name or RFC.
400ACTION_NOT_ALLOWEDstyleLimitYou reached your plan style limit.
400ACTION_NOT_ALLOWEDimagesNotInPlan, imageLimitYour plan has no images or the style already has 4.
400VALIDATION_ERRORinvalidImage, imageTooLargeThe image is not PNG or JPG, or is over 2 MB.
400ACTION_NOT_ALLOWEDbatchNotReadyThe batch has not finished yet.
400ACTION_NOT_ALLOWEDxmlNotStoredThat conversion did not store its XML and cannot be generated again.
401UNAUTHENTICATED—The key is missing, invalid or revoked.
402DOCUMENTS_EXHAUSTED—You have no documents left. Buy more or change your plan.
404NOT_FOUND—The conversion or batch does not exist.
413PAYLOAD_TOO_LARGE—The XML is over 5 MB or the ZIP is over 50 MB.
429RATE_LIMITED—You hit the request limit. Wait and retry.
500INTERNAL_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].