Skip to content

Hacienda Costa Rica — Electronic Invoicing (receipts v4.4)

The Hacienda nodes connect your workflows with Costa Rica’s electronic invoicing (electronic receipts v4.4). Floogos builds the XML, computes the numeric key (50 digits), signs it and sends it to Hacienda’s REST API with OAuth2, querying the status.

NodeWhat it does
Hacienda: Issue invoice (haciendaEmitirFactura)Issues an Electronic Invoice (01)
Hacienda: Credit/debit note (haciendaEmitirNota)Issues CN (03) or DN (02) referencing the original
Hacienda: Query status (haciendaConsultarEstado)Status of a document by its numeric key
Hacienda: Representation / QR (haciendaRepresentacion)Generates the printable representation with QR

The nodes use a Hacienda credential. Create it under Credentials → Add → Costa Rica Hacienda with:

FieldDescription
Certificate (.p12)Hacienda’s cryptographic key, base64.
Password (PIN)The .p12 PIN.
ID and TypeThe issuer’s identification (individual/legal/DIMEX/NITE).
ATV user and passwordHacienda environment OAuth2 credentials.
EnvironmentSandbox or Production.
Branch and TerminalThe codes (e.g. 001 / 00001).
Economic activityThe activity code.
  1. Prepare the document as JSON (recipient, items with precioUnitario and codigoTarifa).

  2. Issue with Issue invoice. Floogos builds the XML, computes the key, signs, gets the OAuth2 token, does the reception POST and queries the status.

  3. If left processing, reconcile it with Query status.

  4. Generate the representation with Representation / QR.

Node: Hacienda: Issue invoice. Example:

{
"receptor": { "cedula": "3101999999", "tipoCedula": "02", "nombre": "Cliente SA" },
"items": [
{ "detalle": "Product", "cantidad": 2, "precioUnitario": 50, "codigoTarifa": "08" }
]
}

codigoTarifa: 08 = 13% (general), 01 = 0%, 02 = 1%, 03 = 2%, 04 = 4%. precioUnitario is without VAT. The sequential is auto-numbered if not provided.

Credit/debit note issues a CN (03) or DN (02) that references the original document with referencia (50-digit numeric key, reason code and reason):

{
"tipo": "03",
"referencia": { "clave": "506...", "tipoDoc": "01", "fecha": "2026-07-20", "codigo": "01", "razon": "Return" },
"receptor": { "cedula": "3101999999" },
"items": [ { "detalle": "Product", "cantidad": 1, "precioUnitario": 100, "codigoTarifa": "08" } ]
}

Query status queries a document by its numeric key and returns whether it is accepted, rejected, received or processing, updating the status in the database.

Representation / QR generates the printable representation in HTML (exportable to PDF), with the numeric key and the QR that contains it.

SituationRetryableWhat to do
Reception rejectedNoHacienda returned an error (recipient ID, structure). Fix the document.
Status rejectedNoHacienda did not accept it; check the message detail.
Expired certificateNoRenew the .p12 and update the credential.
Network / TimeoutYesTransient issue; retried automatically.