Skip to content
Documentation sections

Examples by language

Code to copy and adapt. Every example reads the base URL from FD_API and the key from FD_API_KEY; pick a language and the whole page sticks to it.

Stamp a CFDI

Send the voucher in the json parameter, as a form (application/x-www-form-urlencoded). If it was stamped, the response is HTTP 200 and the UUID comes in cfdi.UUID. If not, it's HTTP 400 and code and message say why. The invoice.json file can be any of the JSON validator examples.

# FD_API=https://sandbox-app.facturadigital.com.mx/api/v5
curl -sS -X POST "$FD_API/invoice/create" \
  -H "X-Api-Key: $FD_API_KEY" \
  --data-urlencode "json@invoice.json"

Check the folio balance

Use it to confirm the key and the URL belong to the same environment before stamping. It returns balance with your available folios.

curl -sS "$FD_API/account/balance" -H "X-Api-Key: $FD_API_KEY"

Cancel a CFDI

Parameters go in HTTP headers, not in the body: UUID, MOTIVO (02 if you don't send it) and FOLIOSUSTITUCION with reason 01. Reasons and responses are in the cancellation guide.

curl -sS -X POST "$FD_API/invoice/cancel" \
  -H "X-Api-Key: $FD_API_KEY" \
  -H "UUID: 6FA90F39-2D7A-4F1C-9B3E-5C1D8A0E7B42" \
  -H "MOTIVO: 02"

Checked against the production API v5 on 2026-11-03.