Sign an invoice and return its consecutivo/clave (no ATV submit)
const url = 'https://api.emite.cr/v1/invoices/01a00c73-5c07-7bb5-8b9e-d20f16537e42/sign?submit=async';const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Example
01a00c73-5c07-7bb5-8b9e-d20f16537e42Invoice UUID
Query Parameters
Section titled “Query Parameters”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.
Responses
Section titled “Responses”Fiscal number allocated and XML signed (also on a repeated call, with the same number).
object
Invoice UUID
20-digit consecutivo (sucursal+terminal+docType+sequence).
50-digit Hacienda clave. Embeds the emission date, situación digit and a security code — print it on the voucher (QR to Hacienda verification).
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').
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.
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).