Skip to content

Document types

Every document carries a docType. It selects the XML root element, the required fields, and how Hacienda treats the document. All emission types go through the same POST /v1/invoices + POST /v1/hacienda/submit/:id pipeline.

docType Name Use it for
01 Factura Electrónica (FE) A sale to an identified receiver (needs a receiver)
02 Nota de Débito (ND) Increase the value of an existing document
03 Nota de Crédito (NC) Reduce or annul an existing document
04 Tiquete Electrónico (TE) A sale with no identified receiver (retail/POS)
05 Confirmación de Aceptación Accept a document you received (MensajeReceptor)
06 Confirmación de Aceptación Parcial Partially accept a received document
07 Rechazo de Comprobante Reject a received document
08 Factura Electrónica de Compra (FEC) Purchases from a supplier not required to issue electronic comprobantes (you self-invoice)
09 Factura Electrónica de Exportación (FEE) Exports to a foreign buyer
10 Recibo Electrónico de Pago (REP) Acknowledge a payment received against credit sales

Types 05/06/07 are MensajeReceptor documents — they’re not emitted through the invoice endpoint but over a received document; see Received documents.

  • TE (04) — no receiver block required. This is the default for retail / POS where the customer doesn’t ask for a nominal invoice.
  • FE (01) — requires a receiver (receiver inline or receiverId). Use it when the buyer needs the document under their tax ID (to claim IVA credit).

The full payload and receiver rules are in Create an invoice.

An FE, a TE or an FEE issued in place of another document, rejected or annulled, cites it with 07, 15 or 16: see Replace a document.

Adjust an already-issued document. They require a references[] array pointing at the source. Full guide: Notas de Crédito / Débito.

FEC — Factura Electrónica de Compra (08)

Section titled “FEC — Factura Electrónica de Compra (08)”

You self-invoice a purchase from a supplier who is not required to issue electronic comprobantes: an inscribed supplier of a special regime (simplificado, for example), a foreign supplier with no domicile in Costa Rica, or a private person selling you used goods. You allocate the number, sign and submit the document; in the XML the roles are inverted — the supplier is the <Emisor> and your tenant the <Receptor> — and the clave carries your cédula, since you are the one Hacienda hears from.

The payload is the FE’s with docType: '08', and the receiver block is the supplier:

  • identificationType 01–04 for an inscribed supplier (a domicile — location — is required, as for any Emisor: SUPPLIER_LOCATION_REQUIRED); 05 for a foreign, non-domiciled one (otrasSenasExtranjero, 5–300 chars, replaces the location: SUPPLIER_FOREIGN_ADDRESS_REQUIRED); 06 (no contribuyente) only for used goods, with saleCondition: '13' (SUPPLIER_NO_CONTRIBUYENTE_REQUIRES_CC_13).
  • references[] is required and names the supplier’s document, which is not one of yours: an external reference — tipoDocIR (14 comprobante de régimen especial, 16 comprobante de proveedor no domiciliado, 99 otros with tipoDocRefOTRO), numero (as the supplier issued it, 1–50 chars), fechaEmisionIR (ISO 8601, not in the future nor older than 10 years), codigo (typically 04 Referencia, or 11 Proveedor No Domiciliado) and razon. Hacienda ties the supplier’s type to the reference: a 05 supplier references a 16 document, and only a 05 supplier does (FEC_REFERENCE_TIPO_MISMATCH). The one document of yours an FEC may reference is a previous FEC it replaces (invoiceId, declared as 15).
  • The line has no ImpuestoAsumidoEmisorFabrica, no per-unit excise data and no surtido (LINE_NOT_ALLOWED_FOR_DOCTYPE); an exoneración is fine.
{
"docType": "08",
"receiver": { "identificationType": "05", "identificationNumber": "US-EIN-12-3456789",
"name": "Cloud Tools International LLC",
"otrasSenasExtranjero": "1234 Ocean Ave, Miami, FL 33101, USA" },
"saleCondition": "01",
"paymentMethods": [{ "type": "04" }],
"references": [{ "tipoDocIR": "16", "numero": "INV-88213",
"fechaEmisionIR": "2026-09-15T12:00:00-06:00",
"codigo": "11", "razon": "Compra de servicios a proveedor no domiciliado" }],
"lines": [ … ]
}

A credit or debit note over an FEC references it by invoiceId like any other document; the snapshot declares tipoDocIR 17 (NC) or 18 (ND), the codes nota 10 reserves for a note over an FEC, and the note’s XML keeps the FEC’s inverted roles.

FEE — Factura Electrónica de Exportación (09)

Section titled “FEE — Factura Electrónica de Exportación (09)”

An export sale to a foreign buyer. Commonly issued in a non-CRC currency with a TipoCambio, and the receiver may be a foreign party (identificationType: '05' with otrasSenasExtranjero).

The payload is the FE’s with docType: '09', but Hacienda’s export schema is narrower than the FE’s, so a few things an FE can carry are refused with LINE_NOT_ALLOWED_FOR_DOCTYPE (params.reason):

  • Every line carries IVA, exempt: codigoTarifa: '10' (Ley 9635, art. 8). Any other tariff is refused first by the API (export_tariff, surtido components included): the 0 % rate '01' is for other transactions (RLIVA art. 32) and Hacienda rejects it on an export (-101), and a taxed line is rejected too (-111/-107). A line with no IVA would be no sujeto, a total the export summary doesn’t have (no_iva).
  • No exoneraciones (exoneration), no excise with per-unit data (excise_data) and no IVA assumed by the issuer — a regalía or bonificación discount on a line that carries IVA (assumed_tax).
  • Goods need their customs heading: a line whose CAByS starts with 0–4 requires a 12-character partidaArancelaria (PARTIDA_ARANCELARIA_REQUIRED).

Records a payment collected on an invoice sold with deferred IVA — sale condition 08 (servicios prestados al Estado) or 10 (venta a crédito en IVA hasta 90 días, art. 27 LIVA). The IVA of those sales is reported when the money comes in, and the REP is what reports it: one per collection, partial payments included.

It is a different document from the FE, not the FE with another docType:

  • saleCondition is 09 (pays an 08 invoice) or 11 (pays a 10 one) — REP_REFERENCE_CC_MISMATCH otherwise — and references[0].invoiceId names the FE it pays (REP_REFERENCE_MUST_BE_FE), which must be accepted (REFERENCE_NOT_ACCEPTED). The receiver is that invoice’s receptor (REP_RECEIVER_MISMATCH) and never a non-domiciled one. Its codigo is 17 («Pago a comprobante electrónico», the one Hacienda reserves for the REP since 1 November 2026); the 04 used before is still accepted.
  • Each line is a payment on a line of the invoice: description (say at least which instalment it is), unitPrice = the amount collected before IVA with quantity: 1, one IVA tax at the invoice line’s tariff, subtotal and total. No code (CAByS), no discounts, no exoneración, no tax but IVA — the XSD has no element for them (LINE_NOT_ALLOWED_FOR_DOCTYPE with discount / non_iva_tax / no_iva). unitOfMeasure is stored but not emitted; transactionType and commercialUnitOfMeasure are refused (transaction_type / commercial_unit).
  • At least one paymentMethods entry is mandatory; no otherCharges (OTHER_CHARGES_NOT_ALLOWED_FOR_DOCTYPE) and no notes (NOTES_NOT_ALLOWED_FOR_DOCTYPE: the REP schema has no <Otros>).
  • The receipts issued over an invoice — drafts included, as with credit notes — never add up to more than the invoice (REP_EXCEEDS_INVOICE, with total, paid, available, requested). To know how much is left before issuing the next one, read the invoice: GET /v1/invoices/{id} returns paymentBalance, with total, paid and remaining, computed by the same sum that enforces that limit.
{
"docType": "10",
"saleCondition": "11",
"receiverId": "<the invoice's party>",
"paymentMethods": [{ "type": "04" }],
"references": [{ "invoiceId": "<the FE, sold under condition 10>", "codigo": "17",
"razon": "Pago 1 de 2 de la factura 00100001010000000042" }],
"lines": [{ "lineNumber": 1, "description": "Pago 1 de 2 — Servicios de consultoría",
"quantity": 1, "unitOfMeasure": "Otros", "unitPrice": 5000, "subtotal": 5000,
"taxes": [{ "codigo": "01", "codigoTarifa": "08", "tarifa": 13, "monto": 650 }],
"total": 5650 }]
}

The XSD makes <DetalleServicio> optional for a few cases. A document with no lines is valid only when it carries OtrosCargos whose codes are all in {04, 08, 09, 10} (cobro de tercero, depósitos de garantía, multas, intereses). Otherwise → OTHER_CHARGES_REQUIRES_LINE. See Other charges.

OtrosCargos are allowed on FE / TE / NC / ND / FEC / FEE — not on REP.