Skip to content

Consecutivo sequences

Every document gets a 20-digit consecutivo, allocated atomically per (branch, terminal, docType). EmiteCR manages the counter — you never set it per document. The only time you touch it is a migration.

Ventana de terminal
GET /v1/tenants/:tenantId/sequences

Returns the current next-value for each (branch, terminal, docType).

Coming from another provider that already emitted, say, up to consecutivo …000482? Seed the counter so EmiteCR continues from there instead of colliding at …000001:

Ventana de terminal
PUT /v1/tenants/:tenantId/sequences # one entry
PUT /v1/tenants/:tenantId/sequences/batch # many at once

The counter is monotonic-upward only — you can bump it forward, never backward. This is a safety property: Hacienda keeps its own server-side dedup of consecutivos per issuer/branch/terminal/docType, and there’s no API to ask “what was my last consecutivo”, so the counter must only ever grow.

A sandbox reset wipes invoices but preserves invoice_sequences. If the counter were reset to 0, the next emission would hit consecutivo ya existe from Hacienda (which remembers the old numbers) with no way to recover except bumping forward and leaving a gap. In sandbox that gap is harmless — sandbox documents have no fiscal value — so sandbox numbers simply continue where they left off instead of restarting at 1.

Production is stricter. Hacienda’s reception system accepts non-contiguous consecutivos, but the regulation asks for numbering that is strictly consecutive, without gaps, per document type and branch/terminal (Decreto 44739-H, art. 13.4). So once a tenant has ever submitted, the sequence is the single source of truth: it must never be wiped, and it should only be raised to continue numbering you already had (for example, when migrating from another provider) — never past it.