API Reference

Verify a CFE electricity receipt

Send a CFE receipt as a PDF or a photo and get CFE's own copy of it: the holder, the address of the service, and whether the file was edited.

POST /v1/cfe/verify

Checks a CFE electricity receipt (recibo de luz), the usual proof of address in Mexico, with CFE itself. CFE confirms that the service number, the holder's name and the amount to pay belong together, and hands over its own copy of the receipt, which we read and compare with the file you sent.

Use it to onboard a customer from their receipt, to take the address from CFE instead of from a file, and to catch a receipt that was edited. A PDF proves nothing by itself: anyone can change the name or the address on it.

Pricing: 50 credits per receipt CFE answers for, whether it confirms it or not: $0.75 pay-as-you-go, and less under a plan, whose credits cost less. Nothing is charged when CFE cannot be asked.

Request body

Send the receipt as a file, or the three values CFE checks. With a file, any of the three values you also send replaces what was read from it.

Field Type Description
file file or base64 string The receipt: the PDF CFE hands out, a scan, or a photo (PNG or JPEG). Upload it as multipart/form-data, or send it as base64 in JSON; a data: URL prefix is accepted. Up to 8 MB.
service_number string The 12-digit service number (No. de servicio) printed on the receipt.
name string The holder's name exactly as the receipt prints it, cut short if the receipt cuts it short.
total integer The amount to pay (Total a pagar) in whole pesos, as printed: 63 for $63.

PDF, scan or photo

The PDF that CFE's portal and app hand out carries its text, so every field of it is read and compared with CFE's copy. That is the file to ask your customer for.

A photo, or a scan saved as a PDF, is read in two ways. The barcode of the payment stub at the bottom gives the service number, the due date and the amount without mistakes, so it has to be in the picture. The holder's name and the address are read by OCR, with the mistakes OCR makes on a poor picture.

CFE checks the name it is sent, so a name OCR misread comes back as found: false. If you already have the holder's name, send it as name next to the file. When the name cannot be read at all and none was sent, the request is rejected with fields ["name"] and is not charged.

Try it

POST /v1/cfe/verify
Try it

Sign in to send a real request from this page.

New accounts get a $5 USD signup credit, no card required.

or

Example request: the file

curl bash
curl -X POST https://mexcheck.com/v1/cfe/verify \
  -H "x-api-key: rfc_your_api_key" \
  -F [email protected]

Example request: the three values

curl bash
curl -X POST https://mexcheck.com/v1/cfe/verify \
  -H "x-api-key: rfc_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"service_number": "123456789012", "name": "JUAN PEREZ LOPEZ", "total": 63}'

Response (200)

200 OK json
{
  "service_number": "123456789012",
  "found": true,
  "mismatch": null,
  "message": "CFE issued this receipt, and the file matches CFE's copy.",
  "receipt": {
    "service_number": "123456789012",
    "name": "JUAN PEREZ LOPEZ",
    "address": [
      "AV. SIEMPRE VIVA 742",
      "ENTRE UNO Y DOS",
      "COL. CENTRO &C.P.64000",
      "MONTERREY, N.L.,N.L."
    ],
    "address_parts": {
      "street": "AV. SIEMPRE VIVA 742",
      "between_street": "ENTRE UNO Y DOS",
      "neighborhood": "COL. CENTRO",
      "zip": "64000",
      "city": "MONTERREY",
      "municipality": "Monterrey",
      "municipality_code": "039",
      "state": "Nuevo León",
      "state_code": "19"
    },
    "zip": "64000",
    "total": 63,
    "due_date": "2026-11-16",
    "period_start": "2026-08-28",
    "period_end": "2026-10-29",
    "tariff": "1C",
    "meter": "ZZZ000",
    "account": "01DD00A000000000"
  },
  "document": {
    "source": "pdf",
    "age_days": 0,
    "same_receipt": true,
    "compared": [
      "service_number", "name", "address", "zip", "total", "due_date",
      "period_start", "period_end", "tariff", "meter", "account"
    ],
    "matches_cfe": true,
    "differences": [],
    "alert": null,
    "data": {
      "service_number": "123456789012",
      "name": "JUAN PEREZ LOPEZ",
      "address": [
        "AV. SIEMPRE VIVA 742",
        "ENTRE UNO Y DOS",
        "COL. CENTRO &C.P.64000",
        "MONTERREY, N.L.,N.L."
      ],
      "zip": "64000",
      "total": 63,
      "due_date": "2026-11-16",
      "period_start": "2026-08-28",
      "period_end": "2026-10-29",
      "tariff": "1C",
      "meter": "ZZZ000",
      "account": "01DD00A000000000"
    }
  }
}

found

Value Meaning Charged
true CFE confirms that the service number, the holder's name and the amount to pay belong together. Yes
false CFE says they do not: the service does not exist, or the name or the amount is not the one on its records. message carries CFE's own words. Yes
null CFE could not be asked. Try again later. No

When CFE refuses: mismatch

When found is false, mismatch names the value CFE refused, and message carries CFE's own words.

mismatch Meaning
"name" The holder's name is not the one CFE has for that service. On a photo, check first whether OCR misread it: document.data.name shows what was sent.
"total" The amount is not that of the service's last two receipts. CFE confirms no older ones, so a genuine receipt from months ago is refused the same way.
null CFE's answer names neither, as when it does not know the service number.

To tell an old receipt from a forged one, look at document.age_days, the days since the receipt fell due. When CFE refuses the amount of a receipt that fell due more than 120 days ago, message says that it may be genuine and too old to check. Ask your customer for a recent receipt.

200 OK json
{
  "service_number": "123456789012",
  "found": false,
  "mismatch": "total",
  "message": "El total a pagar no coincide con nuestro registro, favor de validar la información con su último o penúltimo recibo. (This receipt fell due 364 days ago. CFE only confirms a service's last two receipts, so it may be genuine and too old to check: ask for a recent one.)",
  "receipt": null,
  "document": {
    "source": "pdf",
    "age_days": 364,
    "same_receipt": null,
    "compared": [],
    "matches_cfe": null,
    "differences": [],
    "alert": null,
    "data": {"service_number": "123456789012", "total": 61, "due_date": "2025-11-17", "...": "..."}
  }
}

receipt: CFE's own copy

What CFE's copy of the receipt prints: the holder, the address of the service as lines with its zip code apart, the amount to pay, the due date, the billing period, the tariff, the meter and the account. It is the receipt for the month of the file you sent when CFE still lists it, otherwise the latest one. This is the address to keep.

address is the address as the receipt prints it, line by line. address_parts is the same address from CFE's record of the bill, in fields of its own: street (with its number), between_street, neighborhood (the colonia), zip, city (the town, as CFE writes it) and municipality_code, the municipality's INEGI code within its state. municipality, state and state_code are filled in from our zip code catalogue when it has that zip code under that municipality; otherwise state is CFE's abbreviation and the other two are null.

The two come from two files of CFE's, and either can be missing: address_parts is null when CFE did not hand its record over, and address is null when only the record could be read. CFE's record writes accented letters and Ñ as a question mark; we put the letter back from the printed receipt when we have it.

document: the file you sent

Present when a file was sent, null otherwise.

Field Description
source "pdf" for CFE's own PDF, read whole from its text. "photo" for a photo or a scan, read from its barcode and by OCR.
age_days Days since the receipt fell due, in Mexico City's calendar. Negative while it is not yet due.
data What the file prints, in the fields of receipt. For a photo only the service number, the due date, the amount, the holder and the address are read; the rest is null.
same_receipt Whether CFE's copy is the same bill as the file: the same billing period for a PDF, the same due date for a photo.
compared The fields compared with CFE's copy. Every field for a PDF of the same bill; the service number, holder, address and zip code when CFE's copy is another bill; the barcode's service number, amount and due date for a photo.
matches_cfe, differences Whether the compared fields agree with CFE's copy, and the names of the ones that do not.
alert "edited" when the file differs from CFE's copy of the same bill. "outdated_or_edited" when it differs from another bill of the service, whose holder may have changed since. null when nothing differs.

The holder and the address of a photo are not compared, because OCR is too unsure to call a file edited over. For a photo, take them from receipt.

A receipt that was edited

The address on this PDF was changed. CFE still confirms the service, since its number, holder and amount were left alone, and its own copy shows the difference.

200 OK json
{
  "service_number": "123456789012",
  "found": true,
  "message": "CFE issued a receipt for this service, but the file differs from CFE's copy of it.",
  "receipt": {
    "name": "JUAN PEREZ LOPEZ",
    "address": ["AV. SIEMPRE VIVA 742", "ENTRE UNO Y DOS", "COL. CENTRO &C.P.64000", "MONTERREY, N.L.,N.L."],
    "...": "..."
  },
  "document": {
    "source": "pdf",
    "same_receipt": true,
    "matches_cfe": false,
    "differences": ["address"],
    "alert": "edited",
    "data": {
      "name": "JUAN PEREZ LOPEZ",
      "address": ["AV. SIEMPRE VIVA 999", "ENTRE UNO Y DOS", "COL. CENTRO &C.P.64000", "MONTERREY, N.L.,N.L."],
      "...": "..."
    }
  }
}

Errors

A request that cannot be checked returns 422 with error invalid_fields and fields listing what is missing or invalid, and is not charged: ["file"] for a file that is not a CFE receipt, or a photo without its payment barcode; ["name"] for a photo whose holder could not be read; the values themselves when a service number is not 12 digits or a total is not whole pesos. See the errors page for the codes every endpoint shares.