Skip to Content
SelloDeveloper docs
Guides

The clave

The field-composed 50-digit Hacienda key.

Every Costa Rica comprobante is identified by a clave — a 50-digit numeric key. It is not a random UUID and not a mod-97 check-digit code: it is field-composed, built by concatenating fixed-width fields. Sello allocates it for you on create; you never supply it.

The 50-digit layout

País(3) + Día(2) + Mes(2) + Año(2) + Cédula(12) + Consecutivo(20)
        + Situación(1) + CódigoSeguridad(8)  =  50 digits
FieldWidthMeaning
País3Country code — always 506 for Costa Rica.
Día / Mes / Año2 + 2 + 2Emission date (CR timezone), DDMMYY.
Cédula12The emisor's identification, left-padded with zeros.
Consecutivo20The 20-digit consecutivo (see below).
Situación1Situation code (e.g. normal issuance).
CódigoSeguridad8An 8-digit random security code.

The 20-digit consecutivo

The Consecutivo slice is itself composed:

Sucursal(3) + Terminal(5) + TipoDocumento(2) + Número(10)  =  20 digits
  • Sucursal — branch (default 001).
  • Terminal — point-of-sale / caja (default 00001).
  • TipoDocumento — the 2-digit document-type code corresponding to your tipo (FE, TE, NC, …).
  • Número — the sequential number for that (emisor, branch, terminal, type), left-padded to 10 digits.

Security code

The final 8 digits are drawn from a cryptographically secure RNG (CSPRNG), not a predictable source. It's the only unguessable component of the clave — every other field is derivable from public invoice data — so a weak RNG would let someone reconstruct a clave.

In practice

Sello returns the allocated clave and numeroConsecutivo in the 201 (or 200 on an idempotent replay) response to a create, and the clave is your handle for every follow-up call (GET /v1/documents/{clave}, PDF, email, webhooks). It always matches ^\d{50}$.

You never construct or validate the clave yourself — the engine composes it, guarantees uniqueness of the consecutivo per emisor/branch/terminal/type, and it is what Hacienda keys the document on.

On this page