Situación & contingency
Every document records a situación — the circumstance under which it was
issued. It’s digit 42 of the clave, and Costa Rica’s regulation (Decreto
44739-H and the v4.4 Anexos) defines each value:
situacion |
Meaning | When |
|---|---|---|
1 |
Normal | The default — issued and submitted online. Also the right value while Hacienda is down (below). |
2 |
Contingencia | The electronic document that replaces a provisional receipt, handed out while your invoicing system could not be used. With a cloud system such as EmiteCR, that includes the business losing its internet connection. |
3 |
Sin internet | A document generated and signed at the moment of the sale by a system without internet access, and submitted once connectivity returns. A cloud system cannot do that. |
{ "docType": "04", "situacion": 1, "lines": [/* … */] }If you omit situacion, it defaults to 1.
When Hacienda is down
Section titled “When Hacienda is down”Use situación 1 and nothing else. EmiteCR signs the document and keeps its
number; when Hacienda doesn’t answer (unreachable, timeout, 5xx, 408 or 429)
the submit fails with 502 while the document stays signed, and a
background sweep delivers it once Hacienda answers again. That is what the
regulation asks for — store the documents and submit them when the link is
re-established — and in this case it forbids handing out a provisional
(Decreto 44739-H, art. 21). Don’t mark these documents 2 or 3.
Situación 2: replacing a provisional receipt
Section titled “Situación 2: replacing a provisional receipt”When the invoicing system cannot be used, the regulation has the business hand out a provisional receipt and, within two business days after the contingency ends, issue the electronic document that replaces it, referencing it (art. 23). With a cloud system, that includes the business losing its internet connection: without it the document cannot be generated or signed.
The replacing document is an invoice (01) or a ticket (04) with situación
2 and one reference to the provisional: type 08 (“Comprobante emitido en
contingencia”), code 05 (“Sustituye comprobante provisional por
contingencia”), the receipt’s number in numero and its date and time in
fechaEmisionIR:
{ "docType": "04", "situacion": 2, "references": [ { "tipoDocIR": "08", "numero": "POS-20261107-0012", "fechaEmisionIR": "2026-11-07T20:15:00-06:00", "codigo": "05", "razon": "Sustituye comprobante provisional por contingencia" } ], "lines": [/* … */]}The document is dated the moment it’s generated: don’t send fechaEmision.
The provisional’s date, in the reference, is the one that counts as its
emission date (art. 13.6).
Rules the API enforces, because Hacienda doesn’t check them:
- A situación
2always carries its provisional (400 SITUACION_2_REQUIRES_PROVISIONAL_REFERENCE), and only on an invoice or a ticket (400 SITUACION_2_NOT_ALLOWED_FOR_DOCTYPE). - The provisional is cited with type
08and code05, together and as an external reference (400 PROVISIONAL_REFERENCE_INVALID), one per document (400 PROVISIONAL_REFERENCE_DUPLICATE), and only with situación2(400 PROVISIONAL_REFERENCE_REQUIRES_SITUACION_2). - Its date can’t be after today nor more than 30 days old
(
400 PROVISIONAL_FECHA_OUT_OF_RANGE). - Each provisional is replaced once. If you issue the sale with the same
externalReferencein every attempt, the API never creates two documents for it (see below).
The provisional receipt is the business’s paper, not EmiteCR’s. The regulation asks for the legend “comprobante provisional” at the top, in characters of at least 3 mm, and at the bottom “Este comprobante no puede ser utilizado para fines tributarios, por lo cual no se permitirá su uso para respaldo de créditos o gastos”, plus the same information as the electronic document.
Situación 3 and fechaEmision
Section titled “Situación 3 and fechaEmision”Situación 3 is for a system that generates and signs the document at the
moment of the sale, without internet, and submits it no later than two
business days after (art. 21). That document declares its real moment in
fechaEmision, so both the clave (its DDMMYY segment) and the
<FechaEmision> element reflect it:
{ "docType": "04", "situacion": 3, "fechaEmision": "2026-07-18T20:15:00-06:00", "lines": [/* … */]}Rules:
- The API accepts
fechaEmisiononly withsituacion3(400 FECHA_EMISION_REQUIRES_SITUACIONotherwise): the Anexos admit an emission date earlier than the validation only in that case. - It’s bounded to a 30-day look-back and can’t be in the future beyond a
small tolerance (
400 FECHA_EMISION_OUT_OF_RANGE). - Use an ISO 8601 timestamp with the Costa Rica offset (
-06:00). Theclaveand<FechaEmision>are computed in Costa Rica local time.
EmiteCR signs in the cloud, so a document requested from it after an offline
sale was not generated at the moment of the sale: that case calls for
situación 2, with its provisional.
A point of sale without a connection
Section titled “A point of sale without a connection”A point of sale that keeps selling without internet hands out a provisional
receipt and keeps the sale. When the connection returns, it issues the
situación 2 document that cites it.
If the point of sale is online but the number doesn’t arrive in time, it can’t
know whether the document was already issued, and must not hand out a
provisional without knowing. First, close the door: find the draft by its
externalReference (GET /v1/invoices?externalReference=…) and delete it with
DELETE /v1/invoices/{id}. The delete and the allocation of the number race on
the same row and only one wins. If the delete wins, that draft will never get a
number and you can hand out the provisional; if the number won, the delete
answers 409 INVOICE_HAS_FISCAL_NUMBER with the consecutivo, and that is the
sale’s document.
Use the same externalReference in every attempt for a sale: that way there
are never two documents for it (see
Idempotency & retries). The
Idempotency-Key, on the other hand, changes when the body changes: for 24
hours, the one of the situación 1 attempt answers
422 IDEMPOTENCY_KEY_REUSED_DIFFERENT_PAYLOAD to a different body.