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.
The catalog
Section titled “The catalog”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.
FE vs TE — the everyday choice
Section titled “FE vs TE — the everyday choice”- 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 (receiverinline orreceiverId). 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.
NC / ND (03 / 02)
Section titled “NC / ND (03 / 02)”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:
identificationType01–04for an inscribed supplier (a domicile —location— is required, as for any Emisor:SUPPLIER_LOCATION_REQUIRED);05for a foreign, non-domiciled one (otrasSenasExtranjero, 5–300 chars, replaces the location:SUPPLIER_FOREIGN_ADDRESS_REQUIRED);06(no contribuyente) only for used goods, withsaleCondition: '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(14comprobante de régimen especial,16comprobante de proveedor no domiciliado,99otros withtipoDocRefOTRO),numero(as the supplier issued it, 1–50 chars),fechaEmisionIR(ISO 8601, not in the future nor older than 10 years),codigo(typically04Referencia, or11Proveedor No Domiciliado) andrazon. Hacienda ties the supplier’s type to the reference: a05supplier references a16document, and only a05supplier does (FEC_REFERENCE_TIPO_MISMATCH). The one document of yours an FEC may reference is a previous FEC it replaces (invoiceId, declared as15).- 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–4requires a 12-characterpartidaArancelaria(PARTIDA_ARANCELARIA_REQUIRED).
REP — Recibo Electrónico de Pago (10)
Section titled “REP — Recibo Electrónico de Pago (10)”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:
saleConditionis09(pays an08invoice) or11(pays a10one) —REP_REFERENCE_CC_MISMATCHotherwise — andreferences[0].invoiceIdnames the FE it pays (REP_REFERENCE_MUST_BE_FE), which must beaccepted(REFERENCE_NOT_ACCEPTED). Thereceiveris that invoice’s receptor (REP_RECEIVER_MISMATCH) and never a non-domiciled one. Itscodigois17(«Pago a comprobante electrónico», the one Hacienda reserves for the REP since 1 November 2026); the04used 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 withquantity: 1, one IVA tax at the invoice line’s tariff,subtotalandtotal. Nocode(CAByS), no discounts, no exoneración, no tax but IVA — the XSD has no element for them (LINE_NOT_ALLOWED_FOR_DOCTYPEwithdiscount/non_iva_tax/no_iva).unitOfMeasureis stored but not emitted;transactionTypeandcommercialUnitOfMeasureare refused (transaction_type/commercial_unit). - At least one
paymentMethodsentry is mandatory; nootherCharges(OTHER_CHARGES_NOT_ALLOWED_FOR_DOCTYPE) and nonotes(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, withtotal,paid,available,requested). To know how much is left before issuing the next one, read the invoice:GET /v1/invoices/{id}returnspaymentBalance, withtotal,paidandremaining, 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 }]}Line-less documents
Section titled “Line-less documents”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.
Supported for OtrosCargos
Section titled “Supported for OtrosCargos”OtrosCargos are allowed on FE / TE / NC / ND / FEC / FEE — not on REP.