Skip to content

Notas de Crédito / Débito

Hacienda represents adjustments to an already-issued document as doc types:

  • 03 — Nota de Crédito: reduce or annul (returns, post-emission discounts, write-offs).
  • 02 — Nota de Débito: increase (post-emission charges).

Both use the SAME endpoint as a regular invoice (POST /v1/invoices). The difference is the docType plus a mandatory references[] array pointing at the source document.

Ventana de terminal
curl -X POST https://api.emite.cr/v1/invoices \
-H "x-api-key: $EMITECR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"docType": "03",
"receiverId": "9f3b8c1d-…",
"currency": "CRC",
"saleCondition": "01",
"paymentMethods": [{ "type": "01" }],
"references": [{ "invoiceId": "7c2a9b38-…", "codigo": "01", "razon": "Anulación por error en el monto" }],
"lines": [
{
"lineNumber": 1,
"code": "8399000000000",
"quantity": 1,
"unitOfMeasure": "Sp",
"description": "Anulación: Servicio enero",
"unitPrice": 100000,
"subtotal": 100000,
"taxes": [{ "codigo": "01", "codigoTarifa": "08", "tarifa": 13, "monto": 13000 }],
"total": 113000
}
]
}'

references[] is required for docType in {02, 03} (and for a REP, which pays an invoice, and an FEC, which backs a purchase with the supplier’s document — see Document types); forbidden on the others. Lines describe the adjustment, not the original — commonly the same values with a description like “Anulación de…”.

A reference has one of two shapes. A note (and a REP) uses the internal one — a document of yours, by id:

type CreateInvoiceReferenceDto = {
invoiceId: string; // UUID of an existing same-tenant invoice
codigo: CodigoReferencia; // see enum
codigoReferenciaOTRO?: string; // required iff codigo === '99' (5–100 chars)
razon: string; // required (max 180) — Hacienda rejects a reference without it (-131)
};

The external one — a document that is not one of yours, described by hand (tipoDocIR + numero + fechaEmisionIR instead of invoiceId) — belongs to the FEC (the supplier’s document) and to an FE with sale condition 12. On a note it is refused: REFERENCE_INVOICE_REQUIRED.

The XSD allows 1–10 references, but more than one is only valid as a financial note: every reference must use 09 on a credit note or 10 on a debit note (Hacienda error -451, enforced by the API as REFERENCE_MULTIPLE_REQUIRES_FINANCIERA). An annulment therefore always references exactly one document.

codigo Meaning
01 Anula documento de referencia (full annulment)
02 Corrige monto (Anexo 4.4, nota 9 — the XSD’s inline text still says «Corrige texto», from 4.3)
04 Referencia a otro documento
05 Sustituye comprobante provisional por contingencia
06 Devolución de mercancía
07 Sustituye comprobante electrónico — carried by the document issued in place of one annulled with 01 (see «Replace a document»)
08 Factura endosada
09 Nota de crédito financiera
10 Nota de débito financiera
11 Proveedor no domiciliado
12 Nota de crédito financiera por exoneración posterior a la facturación. Credit notes only
13 Anula documento de referencia por error material — the same rules as 01, with the effect in the period of the annulled document. Notes only
14 Corrige monto por error material, with the effect in the period of the corrected document. Notes only
15 Sustituye comprobante electrónico por error material — the document issued in place of one annulled with 13. Never on a note
16 Sustituye comprobante electrónico rechazado — the referenced document has to be rejected (REFERENCE_NOT_REJECTED). Never on a note
17 Pago a comprobante electrónico — on an electronic payment receipt only
99 Otros — requires codigoReferenciaOTRO

Hacienda added codes 13 to 17 in the update of the Anexo of 22 April 2026, mandatory from 1 November 2026. A code the document cannot carry is refused when it is created, before a number is spent (REFERENCE_CODE_NOT_ALLOWED_FOR_DOCTYPE): the credit-note XSD does not accept 17, and Hacienda would reject the note by schema.

With 01, 02 and 06 the note’s effect is declared in its own period; with 13 and 14, in the period of the document the note modifies (Anexo nota 9), whose return has to be reviewed. Choosing between 01 and 13, or 02 and 14, is the issuer’s tax decision. EmiteCR’s reports count every note in the month of its emission date, whatever its code.

Given an invoiceId, the service looks up the referenced document (same-tenant only) and freezes its identifying fields into the NC/ND at creation:

  • tipoDocIR ← the code nota 10 has for the source: 01–04 for an FE, ND, NC or TE (the same numbers as its docType); over an FEC, which nota 10 has no code for, an NC declares 17 and an ND 18 («Nota de Crédito / Débito a Factura Electrónica de Compra»), and the note’s XML keeps the FEC’s inverted Emisor/Receptor roles (the supplier as Emisor); over an FEE, 19 («Factura Electrónica de Exportación», since the update of the Anexo of April 2026; before that the API declared 01). A note over a REP is refused with REFERENCE_TARGET_NOT_ALLOWED
  • numero ← source clave
  • fechaEmisionIR ← source fechaEmision, the emission date its XML declares (not when its draft was saved)

These are frozen — later edits to the source don’t retroactively mutate the NC/ND. The XML emits them as <InformacionReferencia>.

  • Full annulment — codigo: "01", lines copy the original.
  • Return of goods (partial) — codigo: "06", lines for the returned amount.
  • Annulment for a material error — codigo: "13", lines copy the original, and the effect is declared in the period of the annulled document.
  • Amount correction for a material error — codigo: "14", one line with the difference, with the effect in the period of the corrected document.
  • Amount correction — codigo: "02", one line with the difference to credit (NC) or debit (ND).
  • Post-emission charge (ND) — docType: "02", codigo: "04", lines for the extra charge.

Annul a document without building the note

Section titled “Annul a document without building the note”

A full annulment needs no copied lines: ask for the note with POST /v1/invoices/:id/credit-note and EmiteCR builds it from the document as it stored it (its lines with taxes and discounts, its other charges, payment methods, receiver, currency, branch and terminal). Its total is therefore the document’s, to the cent.

Ventana de terminal
curl -X POST https://api.emite.cr/v1/invoices/7c2a9b38-…/credit-note -H "x-api-key: $EMITECR_API_KEY" -H "Content-Type: application/json" -H "Idempotency-Key: $(uuidgen)" -d '{ "razon": "Anulación de la venta", "externalReference": "venta-1042:nc" }'

To annul because of a material error, with the effect in the document’s period, also send "codigo": "13"; without it the note carries 01.

The response is the note as a draft (docType 03, code 01 or 13): sign and send it like any document. The rules in the next section apply the same: only an accepted document is annulled, only once, and the invoices:void scope is required. A tiquete is annulled without a receiver. A retry with the same externalReference answers 409 INVOICE_EXTERNAL_REFERENCE_EXISTS with the note already created in params.invoiceId.

Hacienda’s own validation is lax here — its sandbox accepted two full annulments of the same invoice — so these checks run in the API, before the note exists:

Rule Error
Every credit note, and any note that annuls (01 or 13), requires the invoices:void scope. The issuer role does not have it. 403 INVOICE_REVERSAL_SCOPE_REQUIRED
Only a document Hacienda accepted can be adjusted — not a draft, not one still waiting for an answer, not a rejected one. 422 REFERENCE_NOT_ACCEPTED
A credit note annuls anything but a credit note; a debit note annuls only a credit note (the Anexo’s «nota de débito que elimina una nota de crédito»). 400 ANNUL_TARGET_INVALID
A note carries the same receptor as the document it adjusts (a document without receptor, like a tiquete, imposes none). 400 REFERENCE_RECEIVER_MISMATCH
An annulment is for exactly the document’s total… 422 ANNUL_AMOUNT_MISMATCH
…happens once, whether with 01 or with 13… 409 INVOICE_ALREADY_ANNULLED
…and not on top of partial credit notes (credit what’s left with another code). 409 ANNUL_AFTER_PARTIAL_CREDIT
Credit notes over a document never add up to more than the document. 422 CREDIT_EXCEEDS_AVAILABLE
The same document cannot appear twice in one note’s references. 400 REFERENCE_DUPLICATED
A note carries no 15, 16 or 17, and a debit note no 12 either: it belongs to credit notes. 400 REFERENCE_CODE_NOT_ALLOWED_FOR_DOCTYPE

What counts toward a document’s credited amount: every credit note over it that is a draft, signed, submitted or accepted — a draft reserves its amount (notes cannot be edited after creation, so what it reserves is final). A note stops counting when Hacienda rejects it, it fails, you delete the draft, or a debit note eliminates it. A financial note over several documents counts against each one in proportion to their totals. Two credit notes created at the same time over the same document are serialized: only one can take the last available amount.

The error parameters carry the numbers — available, credited, total, requested and currency — so a client can show what is left to credit.

A document issued in place of another one cites it in its references. An invoice (01), a ticket (04) or an export invoice (09) replaces any of those three, and the code depends on what happened to the earlier one:

What happened to the earlier one codigo TipoDocIR EmiteCR declares
A credit note 01 annulled it 07 The earlier one’s: 01, 04 or 12 («Sustituye Factura de exportación»)
A credit note 13 annulled it 15 The same as with 07
Hacienda rejected it 16 10 («Comprobante electrónico rechazado por el Ministerio de Hacienda»)

With 07 and 15 the reference is not optional: nota 9 of the Anexo says the document generated after an annulment must state code 07, or 15 after a 13. With a rejected one it is optional: a rejected document never existed for Hacienda, and issuing it again without a reference is valid too.

{
"docType": "01",
"references": [
{
"invoiceId": "01a1d9f8-beef-7808-91c5-aeb015c27a9a",
"codigo": "16",
"razon": "Sustitución de comprobante rechazado por Hacienda"
}
]
}

Everything else is a new document: its lines, its number and its receptor, which can be another one (that is how a rejection for a wrong receptor is fixed). GET /v1/invoices/:id says which code the document that replaces it carries (substituteCode: 16, 07, 15, or null when it cannot be replaced now) and which one already replaces it (substitutedByInvoiceId).

Rule Error
Only an invoice, a ticket or an export invoice replaces, and only one of those three. 400 REFERENCE_TARGET_NOT_ALLOWED
The code matches what happened to the earlier one: 16 only over a rejected one… 422 REFERENCE_NOT_REJECTED
…and 07 or 15 only over one annulled with 01 or with 13. 422 REFERENCE_NOT_ANNULLED
A document is replaced once. The replacement counts while it is a draft, signed, submitted or accepted; if Hacienda rejects it, it fails or you delete the draft, the earlier one can be replaced again. 409 REFERENCE_ALREADY_SUBSTITUTED
A debit note does not eliminate the annulment of a document another one already replaces: there would be two documents for the same sale. 409 ANNULMENT_HAS_SUBSTITUTE

Tested in the sandbox on 28 November 2026: Hacienda accepted an invoice replacing a rejected one (16) and a rejected ticket; one replacing an invoice and a ticket annulled with 01 (07); one replacing a document annulled with 13 (15); and an export invoice replacing an annulled one (TipoDocIR 12).

An NC/ND must use the referenced document’s currency — a CRC credit note against a USD invoice breaks the fiscal equivalence of the reversal, so the API rejects the mismatch with REFERENCE_CURRENCY_MISMATCH (all references must also share a single currency).

For non-CRC documents, the exchangeRate behaves differently too: when you don’t send one, the NC/ND inherits the referenced document’s rate (tipoCambioSource: "inherited") instead of fetching today’s BCCR rate — the adjustment reverts the original sale at its own rate. Sending an explicit exchangeRate still wins and is recorded as manual. The same currency match applies to REP (docType: "10"), without rate inheritance (a payment happens today).

Identical to a regular invoice: POST /v1/hacienda/submit/:invoiceId, same async status flow. The XML root becomes NotaCreditoElectronica / NotaDebitoElectronica. ATV may still reject for reasons the API does not check (for example, a referenced clave it does not know) — read haciendaDetailMessage on the rejected NC/ND. Do not count on ATV to catch an over-credit: that is what the rules above are for.

All the normal invoice validations still apply — NC/ND are a doc-type tweak with one extra field, not a payload exception.