Skip to content

FISCALISTO / API / REFERENCE

Replace an invoice · Invoices

Open in ChatGPTOpen in ClaudeOpen in Cursor
POST
/v1/invoices/{id}/substitute

Stamps the corrected invoice (the same body as POST /v1/invoices, related 04) and cancels the previous one with reason 01.

Before you call

  • An issuer that already stamps. In production, with its digital seal (CSD) current: POST /v1/issuers/{id}/certificates. In test mode it stamps with SAT's test CSD.

  • The Idempotency-Key header, a new one for each call (for example, the order's id in your system). If the response is lost, repeat the call with the same one and it isn't done twice: Idempotency.

Authorization

bearerAuth
headerAuthorizationBearer <key>

Your secret key: fk_test_… in test mode, fk_live_… in production. Desarrolladores › Llaves.

Path parameters

id*string

The object's id.

Headers

Idempotency-Key*string

A new one per CFDI (8 to 255 characters; your order id works). If the response is lost, repeat the request with the same value: it answers the same and never stamps twice.

Length8 <= length <= 255

Request body

application/json
  1. body

An invoice (CFDI 4.0). A field that doesn't exist is rejected with parameter_unknown, never ignored.

issuer?string

Issuer (iss_…). If the key has a single issuer or the account has only one, it can be left out.

Pattern^iss_
branch?string

Branch (brn_…) the invoice is issued from: its postal code goes in LugarExpedicion, its address on the PDF and, if it has them, its series. Without it, the issuer's tax address (the Matriz).

Pattern^brn_
cost_center?string

Its cost center (ccn_…): the site, project, branch or department it belongs to, to see income and expenses by center in Reportes. It doesn't change the CFDI. Its credit notes take it on their own.

Pattern^ccn_
warehouse?string

Warehouse (whs_…) its track_stock products come out of. By default, its branch's (or the Matriz's).

Pattern^whs_
customer?|

The customer (Receptor): the id of one from your catalog (cus_…) or their data. Required except on a transfer (type T), whose recipient is the issuer itself.

items*array<>

Line items (Conceptos), at least one.

Items1 <= items <= 200
type?string

I income (by default; with global, global invoice) or T delivery note. Credit notes: POST /v1/credit_notes. Payments: POST /v1/payments.

Default"I"
One of"I""T"
carta_porte?

Carta Porte 3.1 complement (transfer of goods).

carta_porte_exemption?string

Only on a delivery note (type T) without carta_porte: the RMF 2026 rule that allows it. 2.7.7.2.1 own goods on a local transfer (not medicines, hydrocarbons or goods for customs clearance); 2.7.7.2.2 parcel or courier delivery on the first or last mile, one line item per package with its tracking number in sku; 2.7.7.2.3 local towing or salvage truck, relating with related (05) the service's income invoice. Sending it declares that the transfer doesn't cross any stretch under federal jurisdiction. The line items go with unit_price 0 and taxability 01 (the default on a delivery note).

One of"2.7.7.2.1""2.7.7.2.2""2.7.7.2.3"
ine?

INE complement (electoral processes).

leyendas?array<>

Tax legends complement.

Itemsitems <= 10
donation?

Donee complement: a donation receipt. The issuer must be a donee (tax_system 603) with its official letter in donation_authorization (POST /v1/issuers/{id}).

local_taxes?array<>

Local taxes (implocal complement): state transfers and withholdings.

Itemsitems <= 20
export?string

Export (Exportacion), c_Exportacion: 01 not applicable (default), 02 definitive with code A1 (carries comercio_exterior), 03 temporary (without it), 04 definitive with a code other than A1 or without a sale (with or without comercio_exterior; with it, incoterm optional).

One of"01""02""03""04"
comercio_exterior?

Foreign trade complement 2.0.

global?

Global invoice to the general public (InformacionGlobal): frequency, months and year.

use?string

CFDI use (UsoCFDI), a c_UsoCFDI key. G03 by default, or S01 with regime 616.

Pattern^[A-Z]{1,2}\d{2}$
payment_form?string

Payment form (FormaPago), a c_FormaPago key: 01 cash, 03 transfer, 04 credit card, 28 debit, 99 to be defined… Required with PUE; with PPD it's 99.

Pattern^\d{2}$
payment_method?string

Payment method (MetodoPago): PUE (a single payment, the default) or PPD (in installments or deferred, collected with payment complements).

One of"PUE""PPD"
paid_later?boolean

With PUE: true if it hasn't been paid yet («Por cobrar» in the app) even though it will be paid this month.

currency?string

Currency, an ISO 4217 key from c_Moneda (MXN, USD, EUR…). MXN by default.

Length3 <= length <= 3
series?string

Series (Serie), up to 25 characters. Each series has its own folios.

Lengthlength <= 25
notes?string

Remarks that appear on the PDF (they don't go into the XML).

Lengthlength <= 1000
payment_terms?string

Payment terms (CondicionesDePago), up to 1,000 characters without «|»: «Crédito a 30 días», «50 % anticipo». They go in the XML and the PDF; income and expense receipts only. They don't change when it is due (due_date uses the customer's credit days).

Length1 <= length <= 1000
pdf_language?string

PDF language: es (default) or en.

One of"es""en""bi"
addenda?

The recipient's addenda (Walmart, Soriana…), with its own fields.

related?

Related CFDIs (CfdiRelacionados): relation type from c_TipoRelacion and the UUIDs.

exchange_rate?number

Exchange rate to pesos (TipoCambio). Required if the currency isn't MXN; use the DOF's from the previous day.

Range0 < value <= 1000000
folio?integer

Folio (Folio). Fiscalisto assigns the series' next one; only send one if it must be that one.

Range1 <= value <= 2000000000
continue_sequence?boolean

With a chosen folio: true so the following ones continue from that number.

date?string

Issue date (Fecha) if not now, YYYY-MM-DDTHH:MM:SS Mexico City time: up to 72 hours earlier.

Pattern^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$
send_email?boolean

true to send the PDF and the XML by email when stamping, with Fiscalisto's design. Not sent by default.

Defaultfalse
email_cc?|

CC emails, separated by commas.

metadata?

Your own data: up to 50 keys of 40 characters with text values of up to 500. They don't go into the CFDI; they come back in the object and in webhooks.

async?boolean

Only in POST /v1/invoices. true: it answers 202 as soon as the invoice is saved with its folio (status processing) and stamps it after answering; invoice.stamped or invoice.failed say how it ended. On the other routes that receive an invoice it changes nothing.

Defaultfalse

Response body

OK. Repeating the request with the same Idempotency-Key answers the same, with the same status and the idempotent-replayed: true header.

application/json
  1. response

An issued CFDI 4.0: income or global invoice, delivery note, credit note (E), payment complement (P) or payroll receipt (N).

id*string

Object identifier, with its prefix (iss_, inv_, ret_, cus_, prd_, emp_, bat_, brn_, whs_, stm_, adj_, evt_, whe_).

livemode*boolean

true in production (fk_live_ keys), false in test mode (fk_test_). Test objects aren't valid before the SAT.

object*string

What kind of object it is («invoice», «customer»…).

issuer*string

The issuer (iss_…).

branch*|

The branch (brn_…) it was stamped from, or null (the issuer's tax address). Its payments and credit notes follow it.

cost_center*|

Its cost center (ccn_…), or null. The one sent when creating it, or the one set or changed later with POST /v1/invoices/{id}.

type*string

Receipt type (TipoDeComprobante): I income, E expense, P payment, T transfer, N payroll.

One of"I""E""P""T""N"
status*string

processing: the PAC hasn't answered (it resolves on its own; listen for invoice.stamped). valid: stamped. pending: stamped, without the UUID yet (it resolves on its own, like processing). A cancellation waiting on the customer doesn't change status: it stays valid, with cancellation.status pending. rejected: the SAT or the PAC didn't accept it (see error). canceled: canceled.

One of"processing""pending""valid""rejected""canceled"
uuid*|

Tax folio the SAT assigns (UUID of the Timbre Fiscal Digital), in uppercase.

series*|

The series (Serie) it was stamped with, or null.

folio*|

Internal folio. On a rejected one it is the one attempted: it isn't used up, and the series' next CFDI uses it.

date*|

Issue date (Fecha), Mexico City time.

customer*

The customer (Receptor) as it ended up in the CFDI: RFC, name, tax regime and postal code (and foreign if they are abroad).

use*|

CFDI use (UsoCFDI), a c_UsoCFDI key. G03 by default, or S01 with regime 616.

payment_form*|

Payment form (FormaPago), a c_FormaPago key: 01 cash, 03 transfer, 04 credit card, 28 debit, 99 to be defined… Required with PUE; with PPD it's 99.

payment_method*|

Payment method (MetodoPago): PUE (a single payment, the default) or PPD (in installments or deferred, collected with payment complements).

payment_terms*|

Payment terms (CondicionesDePago), up to 1,000 characters without «|»: «Crédito a 30 días», «50 % anticipo». They go in the XML and the PDF; income and expense receipts only. They don't change when it is due (due_date uses the customer's credit days).

notes*|

Note for the customer: it appears on the PDF, not in the XML. Changed after stamping with POST /v1/invoices/{id} (the XML doesn't change; the next PDF carries it).

currency*string

Currency, an ISO 4217 key from c_Moneda (MXN, USD, EUR…). MXN by default.

exchange_rate*|

Exchange rate to pesos (TipoCambio). Required if the currency isn't MXN; use the DOF's from the previous day.

items*array<>

Line items (Conceptos), at least one.

subtotal*|

Sum of the amounts before taxes and discounts (SubTotal).

discount*|

Discount (Descuento).

taxes*|

The receipt's taxes summed by type: IVA and IEPS transferred, IVA and ISR withheld and local taxes; null on a payment complement.

total*|

Total in the receipt's currency (Total).

payment_status*|

Whether it has been collected (Cuentas por cobrar): paid, partial (payment complements or credit notes for part of it) or unpaid. A PUE is paid, except with paid_later until POST /v1/invoices/{id}/mark_paid. null if it isn't income or isn't valid.

amount_due*|

What is left to collect, in its currency, or null.

amount_paid*|

What was collected: valid payment complements and credit notes, or everything if it is a paid PUE. null if it doesn't apply.

paid_on*|

A PUE that was pending collection (paid_later or mark_unpaid): the day the customer paid (YYYY-MM-DD), the one given to POST /v1/invoices/{id}/mark_paid or that of the deposit reconciled with it. null if there is no recorded payment date (a PUE paid when stamped), if it hasn't been paid or if it is PPD (its payments are in its complements).

due_date*|

While it is still to be collected (unpaid or partial): the day it is due (YYYY-MM-DD), its date plus the credit days on the customer's record (or their customer group's) or, without them, the empresa's (30 if you didn't change them); a PUE with paid_later, the last day of its month. These are the days Cuentas por cobrar and the collection reminders use. null if it was already paid or doesn't apply.

related*|

Related CFDIs (CfdiRelacionados): relation type from c_TipoRelacion and the UUIDs.

payment?|

Only on a payment complement (type P).

payroll?

Only on a payroll receipt (type N).

global?

Only on a global invoice.

cancellation*|

The cancellation, if requested: status, reason, replacement and when.

email*|

The email send: to whom, cc to whom and when (null if it hasn't been sent).

error*|

Why the SAT or the PAC didn't accept it: message, SAT code and original text.

recurring_invoice*|

The recurring invoice (rin_…) that stamped it on its own, or null if it was stamped with a call.

tickets*array<string>

The tickets (tkt_…) it invoices: the one your customer invoiced through autofactura, the one your team invoiced from the ticket's page, or the ones associated with it. Empty otherwise; a global invoice's tickets are in GET /v1/tickets with status=global.

origin*|

What stamped the invoice; null if it was stamped outside Fiscalisto.

created_at*|

When it was created, ISO 8601 with Mexico City time (-06:00).

metadata*

Your own data: up to 50 keys of 40 characters with text values of up to 500. They don't go into the CFDI; they come back in the object and in webhooks.

warnings?array<string>

Warnings about the invoice (only in the response that stamps it or, with 202, the one that leaves it processing): it is stamped as sent.

email_error?string

Why the email couldn't be sent; the receipt was stamped.

substitutes?

The invoice this one replaced and whether it was canceled.

advance_application?

The advance payment's application: method, application note and its status.

Errors

  • Stamping requires the Idempotency-Key header (8 to 255 characters, a new one per document), so a retry never stamps twice.

  • The issuer is archived and no longer stamps. Its documents can still be read and canceled.

  • The issuer can't do that yet: the message says what it's missing (its CSD, or one in force when stamping; its RFC and tax details for viáticos). Upload it and repeat the request with the same Idempotency-Key.

  • The account has several issuers and the request doesn't say which: send issuer (iss_…).

  • The object belongs to the other mode: an fk_test_ key only sees test data and an fk_live_ key only live data.

  • Payment complements and credit notes aren't substituted: cancel them and issue another.

  • The account has no live stamps left: to stamp, check RFCs against SAT's lists, look up constancias, request SAT downloads or fetch declarations, the compliance opinion or the mailbox from SAT. Buy a pack in Desarrolladores › Timbres y pagos, or turn on auto-recharge. Never happens in test mode.

  • Live, this part of the API (inventario, portal de proveedores, pedidos, comprobación de gastos) follows the empresa's plan, as in the app: it comes with Operaciones (added to any paid plan; included in Corporativo). The books (the /v1/accounting routes except DIOT, cross checks, IVA refunds and fixed assets) come with Contabilidad (added to Independiente, Emprendedor or Negocio; included in Despacho and Corporativo): without it, changing the books answers this error, and reading them works only up to the last month it had it. Add either in Ajustes › Plan y pagos; test mode has everything.

  • That issuer is an empresa of the app connected to your account: through the API it only offers its Portal de proveedores (/v1/portal_suppliers and /v1/supplier_invoices) and, once someone who may pay suppliers and change Configurar pagos turned them on, its supplier payouts (/v1/payouts and /v1/payroll_payouts). It also stops when whoever connected it (or turned its payouts on) no longer has that permission in the empresa: message_es says which. Do everything else in the app.

  • This key can't use that issuer.

  • There is no such issuer in the account (or it belongs to the other mode).

  • There's no object with that id (or it belongs to another issuer or the other mode).

  • Another request with the same Idempotency-Key is still running. Repeat it in a moment with the same key: it will answer the same.

  • The invoice breaks a SAT rule Fiscalisto checks before sending it to the PAC. No stamp was used. message_es says which rule and how to fix it.

  • The PAC or the SAT didn't accept it. sat_code has their code (CFDI40xxx) and message_es what to fix. No stamp was used.

  • You reached today's limit of something not paid with stamps. Retry-After says how many seconds until midnight in Mexico City.

  • Too many stamps in a row for the same issuer. Wait what Retry-After says; for many invoices use POST /v1/invoice_batches, for a payroll run POST /v1/payroll_batches.

Plus those of any call (key, fields, limits): Errors. They all carry code, message and, when it's about a field, param.

curl -X POST 'https://api.fiscalisto.com/v1/invoices/inv_OufpKqnrvx9p0Nfbydl9jG4UNGeTYcvdrg/substitute' \  -H 'Authorization: Bearer fk_test_…' \  -H 'Idempotency-Key: pedido-A-1042-correccion-1' \  -H 'Content-Type: application/json' \  -d '{  "customer": {    "tax_id": "ICV060329BY0",    "legal_name": "INMOBILIARIA CVA",    "tax_system": "601",    "zip": "33826",    "email": "pagos@cva.example"  },  "payment_form": "03",  "items": [    {      "description": "Mensualidad",      "product_key": "86121700",      "quantity": 2,      "unit_price": 2400    }  ],  "send_email": true,  "metadata": {    "pedido": "A-1042"  }}'
{  "id": "inv_OufpKqnrvx9p2Rk7cV0bWm4sLx9QeT1aZn",  "object": "invoice",  "livemode": false,  "issuer": "iss_OufpKqnrvx9p",  "branch": null,  "cost_center": null,  "type": "I",  "status": "valid",  "uuid": "0B7E2D1C-4A3F-4E8B-9C6D-5A4B3C2D1E0F",  "series": null,  "folio": "2",  "date": "2026-10-24T10:15:42",  "customer": {    "tax_id": "ICV060329BY0",    "legal_name": "INMOBILIARIA CVA",    "tax_system": "601",    "zip": "33826"  },  "use": "G03",  "payment_form": "03",  "payment_method": "PUE",  "payment_terms": null,  "notes": null,  "currency": "MXN",  "exchange_rate": null,  "items": [    {      "description": "Mensualidad",      "product_key": "86121700",      "unit_key": "E48",      "unit_name": "Unidad de servicio",      "sku": "MEN-1",      "quantity": 2,      "unit_price": 2400,      "taxability": "02",      "iva": "0.16"    }  ],  "subtotal": 4800,  "discount": 0,  "taxes": {    "iva": 768,    "ieps": 0,    "iva_withheld": 0,    "isr_withheld": 0,    "local_transferred": 0,    "local_withheld": 0  },  "total": 5568,  "payment_status": "paid",  "amount_due": 0,  "amount_paid": 5568,  "paid_on": null,  "due_date": null,  "related": {    "relationship": "04",    "uuids": [      "5F1E8C2A-3B7D-4C9E-A1B2-C3D4E5F60718"    ]  },  "cancellation": null,  "email": {    "to": "pagos@cva.example",    "cc": null,    "sent_at": "2026-10-24T10:40:12-06:00"  },  "error": null,  "recurring_invoice": null,  "tickets": [],  "origin": {    "type": "api",    "name": "Tienda en línea"  },  "created_at": "2026-10-24T10:15:42-06:00",  "metadata": {    "pedido": "A-1042"  },  "substitutes": {    "invoice": "inv_OufpKqnrvx9p0Nfbydl9jG4UNGeTYcvdrg",    "canceled": true,    "cancellation": {      "status": "accepted",      "motive": "01",      "substitution": "0B7E2D1C-4A3F-4E8B-9C6D-5A4B3C2D1E0F",      "canceled_at": "2026-10-24T10:31:08-06:00",      "next_attempt_at": null,      "error": null    }  }}

Was this page helpful?