Skip to Content
SelloDeveloper docs
API ReferenceEmisores

Seed an emisor's consecutivo series

States the last consecutivo the emisor used AT HACIENDA on one series (`sucursal`, `terminal`, `tipo`), so the next document Sello numbers on it is `lastUsed + 1`. A customer that invoiced through another system has consumed numbers Hacienda will refuse to see again; seed each series before the first production document. `lastUsed: 0` means the series was never used. Restating the current value is a no-op `200`. The seed never lowers a counter. Requires the `documents:write` permission, which permits seeding under the engine's refusal rules. A key pinned to this emisor and an account-wide key of the emisor's account may seed; a key pinned to another emisor answers the `403` *Out of key scope* refusal (`about:blank`, `policy: key.emisor_pin`). A `test` key on a production emisor answers `403` `.../environment-mismatch`. A suspended or closed account may read the series and may not seed them (`403` `.../account-suspended`). **Idempotency-Key (required).** The key is stored with a fingerprint of the emisor and the validated body when the seed completes, in the transaction that commits it. The same key with the same request replays the stored `200` answer with the echoed key, also after a production document was issued on the series and whatever the counter holds now; nothing is written again. The same key with another body or another emisor answers `409` `.../idempotency-key-conflict` and changes nothing; the stored answer stays, and the original request still replays it. A request that lost a race for the key to another request that has not stored its answer answers `409` `.../idempotency-in-flight`. A refused request stores nothing, so a corrected request may reuse its key. Authentication, permission, scope, body, ownership and environment refusals are decided before the key. The engine refuses a seed with `422` `.../consecutivo-seed-refused`, whose `reason` says why (for example `series-has-documents` when Sello already numbered a production document on the series, or `emisor-work-in-flight` with `inFlight` counts while the emisor has work in flight) and whose `series` names the series. Nothing is written. A body that fails validation answers `422` `about:blank` *Invalid request* with the field issues in `errors[]`; a body that is not JSON answers `400` `about:blank` *Malformed JSON body*. An emisor id that is not a UUID, names no emisor, or names another account's emisor answers the same `404` `about:blank` *Emisor not found*.

PUT
/v1/emisores/{emisorId}/consecutivos

Authorization

ApiKeyAuth documents:write
headerAuthorizationBearer <token>

Per-consumer API key sent as a bearer token: Authorization: Bearer <key>. Keys are scoped to a single Sello account (tenant). Modeled as HTTP bearer (not apiKey) so every generated SDK emits the Bearer prefix the engine requires; the scheme name stays ApiKeyAuth for contract stability. Every key belongs to one world, and the key says which. A key minted for production reads sello_live_…; one minted for sandbox reads sello_test_…. Each emisor is likewise production or sandbox, fixed when it is provisioned. A write that binds a key to an emisor — creating a document, ingesting a supplier comprobante, filing a Mensaje Receptor — is checked against that pairing, and the check runs ONE WAY (ADR-0040). A sello_test_ key acting on a production emisor is REFUSED with 403 Wrong key environment: it would sign a legally binding comprobante with the real certificate, burn a real consecutivo and file it with Hacienda, none of which can be undone. A sello_live_ key acting on a sandbox emisor is ALLOWED: it produces a sandbox document, which is never metered, since the emisor alone decides whether a document is billable. That pairing is usually a mis-classified emisor rather than a deliberate choice, so Sello logs it for its own operators — nothing about your request changes. The classification is not the destination (ADR-0067). Which Hacienda hears a document is decided by the emisor's Hacienda endpoints, which are a separate fact from its sandbox / production classification. So a sello_test_ key is refused on a sandbox emisor too when that emisor's endpoints are production endpoints — the same 403 Wrong key environment, because the document would be legally binding whatever the classification says. That combination is a misconfiguration on Sello's side of the line, not something you can fix with a different key: ask Sello to correct the emisor. The refusal follows the KEY, not how it was minted: an account-wide sello_test_ key naming that emisor is refused on the same request path, and a sello_live_ key is unaffected. The prefix is not decoration and not a hint you may edit: it is part of the hashed secret, so a key that authenticates at all is byte-identical to the one Sello minted. Read it to tell your own keys apart; you cannot change a key's world by rewriting it. To move between worlds, use the key that belongs to the world you mean. A key also says which operations it may run (#750). Each /v1 operation names one permission in its security requirement, and a key holds a non-empty set of them, fixed when it is created: documents:read (list, status, PDF, XML), documents:write (create, email), received-documents:read (list, get), received-documents:write (ingest, respond) and webhooks:write (register the endpoint). A key created without naming any holds all five, and so does every key created before permissions existed. A key without the permission an operation needs is refused 403 https://sello.cr/problems/insufficient-permission, naming it in requiredPermission, before anything else the operation does — an idempotent replay included. /reference/* needs no permission: any valid key reads it. To change what a key may do, create a new key and revoke the old one.

Scope: documents:write

Path Parameters

emisorId*string

The emisor whose consecutivo series to read or seed. A UUID, compared case-insensitively; the response names it in lower case.

Header Parameters

Sello-Version?string

Date-based API version (e.g. 2026-06-15). The /v1 path segment is the stable major; this header picks the dated contract. Optional: when it is omitted the server uses the account's pinned version, read from the API key's account after the key is verified. An account's pinned version is set to the deployment's global default when the account is created, and a later change of that default never moves it. A pinned version the server does not serve is 400 https://sello.cr/problems/unsupported-version; the server never answers under another date instead. The value must be exactly a YYYY-MM-DD calendar date with a year from 0001 to 9999 (the server also checks the day exists, leap years included), else 400 https://sello.cr/problems/invalid-version. A valid date the server does not serve is 400 https://sello.cr/problems/unsupported-version; today the only supported date is 2026-06-15. A failure to resolve the version is 503 https://sello.cr/problems/version-resolution-unavailable. The response Sello-Version header carries the resolved date. /reference accepts the header and ignores it.

Match^\d{4}-\d{2}-\d{2}$
Idempotency-Key*string

Caller-generated unique key (UUID recommended) that makes the mutation safe to retry. Replaying the same key returns the original result. Must be 1–255 printable-ASCII characters with no whitespace or control characters (!–~); anything else is a 400.

Match^[!-~]{1,255}$
Length1 <= length <= 255

Request Body

application/json
  1. body

The body of seedEmisorConsecutivo (#2217). Strict: any other member, actorUserId and apiKeyId included, is a 422 about:blank Invalid request.

sucursal*integer

The sucursal of the series.

Range1 <= value <= 999
terminal*integer

The terminal (caja) of the series.

Range1 <= value <= 99999
tipo*string

The document type of the series.

Value in"FE""TE""NC""ND""FEC""FEE""REP""MR"
lastUsed*integer

The last consecutivo used AT HACIENDA on this series; 0 when the series was never used. The next number Sello hands out is lastUsed + 1.

Range0 <= value <= 9999999998

Response Body

The series after the seed, or the replay of the stored answer of a completed request with this Idempotency-Key.

application/json
  1. response

The 200 body of seedEmisorConsecutivo (#2217).

emisorId*string

The emisor the path named, in lower case.

Formatuuid
series*

The series as it stands after the seed.

Example Request
curl -X PUT 'https://api.sello.cr/v1/emisores/string/consecutivos' \  -H 'Idempotency-Key: string' \  -H 'Content-Type: application/json' \  -d '{  "sucursal": 1,  "terminal": 1,  "tipo": "FE",  "lastUsed": 0}'
Example Response
{  "emisorId": "ffed7f26-5af9-4c47-8187-286731b1e596",  "series": {    "sucursal": 1,    "terminal": 1,    "tipo": "FE",    "nextNumber": 1,    "seededAt": "2019-08-24T14:15:22Z"  }}

List an emisor's consecutivo series

Lists every consecutivo series Sello holds for the emisor the path names: one item per `sucursal`, `terminal` (caja) and document `tipo`, with the `nextNumber` the allocator hands out next and `seededAt`, when the series was seeded (null for a series only the allocator wrote). An emisor with no series answers `series: []`. `issued` is true when Sello has numbered a production document on the series, so the plain seed refuses to move it (`series-has-documents`). It is never true for `MR`, whose seed moves forward on its own. Requires the `documents:read` permission. A key pinned to this emisor and an account-wide key of the emisor's account may read; a key pinned to another emisor answers the `403` *Out of key scope* refusal (`about:blank`, `policy: key.emisor_pin`). A `test` key on a production emisor answers `403` `.../environment-mismatch`. A suspended or closed account may still read. An emisor id that is not a UUID, names no emisor, or names another account's emisor answers the same `404` `about:blank` *Emisor not found*.

Read the account's webhook endpoint

What is registered: the `url`, whether delivery is `enabled`, when it was created and last changed, and `managedBy` — `odoo-connection` when an Odoo connection's callback holds the endpoint (the writes then answer `409`), otherwise null. NEVER the signing secret. A `404` when no endpoint is registered. Only an account-wide key may read it; a key pinned to one emisor gets a `403` (#758).