Skip to content

Sign an invoice and return its consecutivo/clave (no ATV submit)

POST
/v1/invoices/{id}/sign
curl --request POST \
--url 'https://api.emite.cr/v1/invoices/01a00c73-5c07-7bb5-8b9e-d20f16537e42/sign?submit=async' \
--header 'Authorization: Bearer <token>'

Phase 1 of the two-phase emit: allocates the consecutivo + 50-digit clave, generates the XML and XAdES-signs it — WITHOUT submitting to Hacienda. No external dependency, so the fiscal number returns fast and reliably even while ATV is slow or down (a POS prints it on the voucher immediately). Idempotent: re-signing returns the SAME number; an already-submitted invoice echoes its current state. The signed document WILL reach Hacienda: either via ?submit=async, a later POST /v1/hacienda/submit/:id, or the server-side reconcile sweep (every allocated number is eventually transmitted — there is no "sign and discard"). With ?submit=async (partner-minted API keys only) the ATV submit is enqueued in the background and the verdict arrives via the invoice.submitted|accepted|rejected|error webhooks.

id
required
string
Example
01a00c73-5c07-7bb5-8b9e-d20f16537e42

Invoice UUID

submit
string
Allowed values: async

Pass async to enqueue the background ATV submit after signing. Restricted to partner-minted API keys (403 ASYNC_SUBMIT_PARTNER_ONLY otherwise) — async callers must consume webhooks or they never learn the Hacienda verdict.

Fiscal number allocated and XML signed (also on a repeated call, with the same number).

Media typeapplication/json
object
invoiceId
required

Invoice UUID

string
consecutivo
required

20-digit consecutivo (sucursal+terminal+docType+sequence).

string
clave
required

50-digit Hacienda clave. Embeds the emission date, situación digit and a security code — print it on the voucher (QR to Hacienda verification).

string
status
required

Invoice status after signing. signed = number allocated + XML signed, not yet at Hacienda. Idempotent calls on an already-emitted invoice echo its current status ('submitted' | 'accepted' | 'rejected').

string
submitEnqueued
required

True when ?submit=async was requested and the background submit job was enqueued. When false with ?submit=async, the reconcile sweep will pick the document up — no number is ever stranded.

boolean
Example
{
"invoiceId": "01a00c73-5c07-7bb5-8b9e-d20f16537e42",
"consecutivo": "00100001010000004521",
"clave": "50601072600310112345600100001010000004521110000001",
"status": "signed",
"submitEnqueued": true
}

Missing or invalid JWT / API key

?submit=async used with a credential that is not a partner-minted API key.

Invoice not found, belongs to a different tenant, or has no branch/terminal assigned.

Invoice belongs to the other environment (INVOICE_ENVIRONMENT_MISMATCH).