Preview a document's line amounts, taxes and totals without issuing it
Take the exact `createDocument` body and answer what a fresh create would sign: each line's amounts and taxes, the `ResumenFactura` totals, and the advisory warnings, computed by the same engine code that issues. Nothing is issued: no consecutivo or clave is allocated, nothing is signed, stored, queued to Hacienda or counted as a document. The `Idempotency-Key` and `Sello-Replay-Only` headers are ignored. The body is held to every `createDocument` rule, so derived line amounts stay required and a wrong one is the same `422` a create returns. Fiscal refusals (issuer identity and profile, the supported scenario matrix, CABYS, net totals, line and summary divergence) are the create refusals, byte for byte apart from `instance`. Issuance prerequisites are NOT checked: reception credentials, series seeding, the signing certificate and the plan's document allowance. A `200` therefore does not guarantee the document can be issued, and a later create validates again. Authorized by `documents:read` OR `documents:write`. Rate-limited on the account budget like any other request.
AuthorizationBearer <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:read
Sello-Version?stringDate-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.
^\d{4}-\d{2}-\d{2}$Sello-Emisor-Id?stringFor an account-wide API key, names the emisor (within the key's account) that acts on the request. An emisor-pinned key ignores/validates it; the header can never widen scope to another account. Required by an account-wide key on writes that need an emisor.
uuidapplication/json- body
FE — Factura Electrónica (doc-type code 01). Requires a receptor.
tipo*stringDocument type discriminator.
"FE""TE""NC""ND""FEC""FEE""REP"emisor*The issuing emisor (tenant emitter). ubicacion is mandatory for the FE-family (FE/TE/NC/ND/FEE) but omitted for REP (condition 4) and a foreign-supplier FEC (emisor ID 05/06 → otrasSenasExtranjero instead), and for an NC or ND to an FEC (tipoDocIR 17 / 18), whose emisor is the FEC's tipo 05 supplier and carries no address at all, so it is not required at the base; the per-tipo variant enforces it.
receptor*The receiver (client). Identificación optional (TE may omit it).
codigoActividad?stringv4.4 — the emisor's actividad económica (CodigoActividadEmisor), in the six-character dot form dddd.d (e.g. 4690.0). Optional: when omitted Sello files the emisor's registered activity — except on an FEC, whose emisor is the SUPPLIER: there the code is the supplier's, Sello never fills yours in, and a 05 or 06 supplier may send none.
When sent, it must be an actividad the emisor actually holds. A taxpayer may hold SEVERAL, and any of them may be filed under: the code registered with Sello at provisioning, or any other code Hacienda's /fe/ae padrón lists as ACTIVE for the emisor. A code in neither is refused with unsupported-scenario (codigo-actividad) BEFORE a consecutivo is spent, because the annex rejects a code that does not exist in the RUT and Hacienda would reject it after. The padrón is read only when the code sent is not the registered one, so an ordinary request never depends on Hacienda being reachable; when it cannot be read, the refusal stands and says so, and the registered code keeps working regardless.
^\d{4}\.\d$sucursal?integerThe sucursal (branch) this document is numbered on — the first three digits of the 20-digit numeroConsecutivo. Hacienda keeps a separate consecutivo series per emisor + sucursal + terminal + document type, and Sello keeps a counter per series. Optional; 1 (001) when omitted, so callers that never sent it are unchanged. A migrating customer seeds each series' last accepted number in the onboarding wizard (step 3, Numeración); a document on an unseeded series starts at 1.
1 <= value <= 9991terminal?integerThe terminal / punto de venta (caja) this document is numbered on — digits four to eight of the 20-digit numeroConsecutivo. Optional; 1 (00001) when omitted. Pairs with sucursal to name the series.
1 <= value <= 999991situacion?stringThe clave's situación (its 42nd digit; annex nota 1). 1 normal — the document is generated and transmitted in the same act. 2 contingencia — this comprobante REPLACES a paper voucher issued during a contingency, and the annex requires it to reference that voucher: send an informacionReferencia entry with tipoDocIR 08 (Comprobante emitido en contingencia) and codigo 05 (Sustituye comprobante provisional por contingencia), naming the voucher in numero; without one the request is refused with unsupported-scenario (situacion). 3 sin internet — generated offline; fechaEmision may then be an EARLIER day, never a later one. Optional; 1 when omitted. Before this field existed the body silently dropped it, so a contingency replacement was filed as a normal document.
"1""1""2""3"codigoActividadReceptor?stringv4.4 — receiver activity code, at root level (not in Receptor), in the same six-character dot form as codigoActividad.
Optional, and checked against the RECEPTOR's /fe/ae padrón when sent: a code Hacienda lists as ACTIVE for that identificación is filed, and anything else is refused with unsupported-scenario (codigo-actividad) before a consecutivo is spent, since the annex rejects a code missing from the receptor's RUT. A receptor Hacienda cannot be asked about — no identificación, an unknown taxpayer, /fe/ae unreachable — is refused the same way. The element is optional on an FE, so omitting it is always accepted. On an FEC it is OBLIGATORY and is the buyer's — yours — so your registered activity is admitted without a padrón read.
^\d{4}\.\d$condicionVenta*CondicionVentav4.4 CondiciónVenta catalog: 01=Contado, 02=Crédito, 03=Consignación, 04=Apartado, 05=Arrendamiento con opción de compra, 06=Arrendamiento en función financiera, 07=Cobro a favor de un tercero, 08=Servicios prestados al Estado a crédito, 09=Pago de servicios prestados al Estado (REP only), 10=Venta a crédito en IVA hasta 90 días (LIVA art. 27 / Reglamento art. 40 bis — the elective deferred-IVA régimen; goes on the FE), 11=Pago de venta a crédito en IVA hasta 90 días (REP only — the REP that documents collection of a code-10 sale), 12=Venta mercancía no nacionalizada, 13=Venta bienes usados no contribuyente, 14=Arrendamiento operativo, 15=Arrendamiento financiero, 99=Otros (see condicionVentaOtros). Codes 10/11 are the REP pair: a code-10 factura defers its IVA débito, and each collection is documented by a REP carrying code 11. THE CATALOGUE IS NOT THE SUPPORTED SET. Sello accepts 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, 12, 13, 14, 15, 99 today, each under its own rules: the published matrix files every code (since matrix 2026-11.21, #548), and refuses the shapes below. 99 requires condicionVentaOtros (5–100 characters), 02 requires plazoCredito, and 12 is permitted on an FE only (annex nota 5). 09 and 11 are permitted on a REP only, and a REP carries nothing else (annex, CondicionVenta row) — under every matrix, so 09 on an FE and 01 on a REP are both refused (condicion-venta). 13 is permitted on a factura electrónica de compra only (annex nota 5, footnote 24), and only from a tipo 06 supplier (No Contribuyente), whose FEC must carry it; an FE, NC or ND carrying it is refused (condicion-venta). 10 is filed on an FE (an NC or ND may repeat it) in CRC with a plazoCredito of 1 to 90 days, an identified receptor, and one IVA rate above zero on every line, with no exoneración and no otros cargos; Sello records the deferral, returns it as deferral on the document read, and sends deferral.lapsed when day 90 ends with a balance outstanding. 11 is filed on a REP collecting one such sale within its outstanding balance. A 10 on a TE, FEC or FEE is refused (condicion-venta). Still refused naming #666, because a tax adviser has not answered: a 10 or 11 in another currency (question 3, the exchange rate), and a 10 on several rates, a zero rate, an exoneración or otros cargos (question 2, how a partial payment is applied across rates).
"01""02""03""04""05""06""07""08""09""10""11""12""13""14""15""99"plazoCredito?integerCredit term in days. REQUIRED when condicionVenta is 02 (Crédito) or 10 (Venta a crédito en IVA hasta 90 días) — the annex makes PlazoCredito obligatory for both — and, when sent under any condición, a whole number from 1 to 99999 (the XSD's totalDigits 5). Under 10 the published matrix caps it at 90 ("hasta 90 días", LIVA art. 27); a higher term is refused (condicion-venta).
1 <= value <= 99999condicionVentaOtros?string5 <= length <= 100medioPago?array<|>v4.4 MedioPago (0..4). Obligatory except under condicionVenta 02, 08 or 10 (a sale on credit), where the annex omits the element; the engine refuses a document with none under any other condición. With several methods each needs its totalMedioPago and they must sum to totalComprobante.
items <= 4medioPagoOtros?stringv4.4 MedioPagoOtros — the description code 99 (Otros) obliges: "Se debe describir puntualmente el medio de pago utilizado", 3 to 100 characters — for a document whose medioPago is written as bare codes. It describes the single 99 entry; an object entry carries its own medioPagoOtros instead, and the two spellings name one element. Refused (unsupported-scenario, medio-pago) when there is no 99 to attach it to, when that entry already describes itself, or when several entries are 99.
3 <= length <= 100otrosCargos?array<>v4.4 OtrosCargos (0..N), emitted before ResumenFactura.
resumenFactura?OPTIONAL. The server computes the tax summary from the lines, the otros cargos and the medios de pago, and signs what IT computed — so a resumen sent here is an ASSERTION about that arithmetic, not an input to it. Omit it and the document issues on the server's numbers. Send one that agrees and nothing changes. Send one that disagrees and the request is a 422 (https://sello.cr/problems/resumen-divergence) naming every field, the value sent and the value computed, with no consecutivo spent. Comparison is exact decimal equality at five places; there is no tolerance band. codigoTipoMoneda is the exception and IS read from here: the currency and its tipo de cambio are facts about the sale that no sum over the lines derives.
otros?The v4.4 Otros block (#671): free text with no tax meaning, not allowed on a REP. Emitted as every OtroTexto (otroTexto first, then textos) before any OtroContenido. Each text is 1 to 500 characters as the XSD counts them.
detalleServicio*array<>At least one line, except on a charge-only document: when every otrosCargos entry is code 04, 08, 09 or 10 the annex (p. 47) lets the comprobante carry no line, and Sello then omits DetalleServicio. Any other empty list is refused as otros-cargos before a consecutivo is spent.
0 <= items <= 1000informacionReferencia?array<>Optional on this type. Send it when the document replaces another: a situación 2 contingency replacement references its provisional voucher (tipoDocIR 08, codigo 05), and a replacement of a rejected comprobante carries codigo 16.
items <= 100The calculation. Not an issuance receipt; carries no clave or consecutivo.
application/json- response
What a fresh create would sign, without a fiscal number (#1318). Every amount and rate is a decimal string spelled as the XML would carry it. A key is present exactly when its element would be emitted for this document type.
tipo*DocumentTipoDocument type discriminator.
"FE""TE""NC""ND""FEC""FEE""REP"fechaEmision*stringThe effective Hacienda timestamp the calculation was judged at.
date-timelineas*array<>resumenFactura*The emitted ResumenFactura. Only elements the document would carry are present; codigoTipoMoneda, totalVenta, totalVentaNeta and totalComprobante always are.
warnings*array<>CABYS warnings, then an exchange-rate warning; empty when none apply.
catalogVersion?stringThe CABYS edition the lines were validated against, when rules were in force.
exchangeRate*The exchange rate a document was signed with. source is caller when the request sent tipoCambio, bccr when Sello filled in the stored BCCR venta rate, and fixed for colones, which are always 1. bccr is the stored BCCR rate the document was compared with, and null when none was read.
issuanceGuaranteed*falseAlways false. Credentials, numbering, certificate and billing are not checked.
falsecurl -X POST 'https://api.sello.cr/v1/documents/calculate' \ -H 'Content-Type: application/json' \ -d '{ "emisor": { "nombre": "string", "identificacion": { "tipo": "01", "numero": "string" }, "correoElectronico": "user@example.com" }, "condicionVenta": "01", "detalleServicio": [], "tipo": "FE"}'{ "tipo": "FE", "fechaEmision": "2019-08-24T14:15:22Z", "lineas": [ { "numeroLinea": 0, "montoTotal": "string", "subtotal": "string", "descuento": "string", "baseImponible": "string", "impuesto": [ { "codigo": "string", "codigoTarifa": "string", "tarifa": "string", "monto": "string", "exoneracion": { "montoExoneracion": "string" } } ], "impuestoNeto": "string", "montoTotalLinea": "string" } ], "resumenFactura": { "codigoTipoMoneda": { "codigoMoneda": "string", "tipoCambio": "string" }, "totalServGravados": "string", "totalServExentos": "string", "totalServExonerado": "string", "totalServNoSujeto": "string", "totalMercanciasGravadas": "string", "totalMercanciasExentas": "string", "totalMercExonerada": "string", "totalMercNoSujeta": "string", "totalGravado": "string", "totalExento": "string", "totalExonerado": "string", "totalNoSujeto": "string", "totalVenta": "string", "totalDescuentos": "string", "totalVentaNeta": "string", "totalDesgloseImpuesto": [ { "codigo": "string", "codigoTarifaIVA": "string", "totalMontoImpuesto": "string" } ], "totalImpuesto": "string", "totalImpAsumEmisorFabrica": "string", "totalIVADevuelto": "string", "totalOtrosCargos": "string", "medioPago": [ { "tipoMedioPago": "string", "medioPagoOtros": "string", "totalMedioPago": "string" } ], "totalComprobante": "string" }, "warnings": [ { "code": "cabys_not_in_catalog", "message": "string", "line": 0, "appliedRate": "string", "catalogRate": "string", "cabys": "string", "suppliedRate": "string", "bccrRate": "string", "bccrDate": "string", "tolerance": "string" } ], "catalogVersion": "string", "exchangeRate": { "tipoCambio": "string", "source": "caller", "bccr": { "valor": "string", "fecha": "2019-08-24" } }, "issuanceGuaranteed": false}Issue an electronic document (FE / TE / NC / ND)
Validate, build the v4.4 XML, allocate the consecutivo + 50-digit clave, sign the comprobante (XAdES-EPES), and persist it. Returns `201 Created` on a fresh issue (or `200 OK` on an idempotent replay) with the allocated `clave`, `numeroConsecutivo`, and `state: "signed"`; the engine then submits to Hacienda out of band, walking the state machine (`signed → submitted → accepted | rejected`). Poll `GET /v1/documents/{clave}` or subscribe to webhooks for the terminal outcome. Mutations require an `Idempotency-Key`: replaying the same key returns the original result without re-issuing (no double-submit to Hacienda). A well-formed document outside the published supported-scenario matrix (https://ca-sello-docs.orangesmoke-cacc8fb5.eastus2.azurecontainerapps.io/docs/guides/supported-scenarios) is refused with a `422` whose `type` is `https://sello.cr/problems/unsupported-scenario`, carrying `matrixVersion`, the distinct `scenarios[]` ids and one `errors[]` entry per offending field. The refusal runs ahead of the consecutivo allocation, the quota charge and the idempotency reservation, so it costs nothing and the same key may be retried with a corrected body. The body is limited to 2 MiB and `detalleServicio` to 1000 lines (Hacienda's maximum); for very large lines the byte limit is the one that binds. Every object in the body is closed: an unknown field anywhere in it is a `422` whose `errors[].path` names it, raised before any consecutivo is allocated. `clave`, `numeroConsecutivo` and `fechaEmision` are allocated by Sello and are refused the same way.
List the account's documents (cursor-paginated)
Return a page of the authenticated account's issued documents, newest composite-ordered by `(created_at, id)` and KEYSET-paginated: pass the previous page's `nextCursor` back as `cursor` to fetch the next page, until `nextCursor` is `null`. The list is scoped to your API key's account (RLS + an explicit account predicate); another account's documents are never visible. An emisor-pinned key sees only its own emisor's documents; an account-wide key sees every emisor in the account. Optionally filter by `tipo`, `state`, `updatedSince`, `internalType`, the signed issue date (`issuedFrom` / `issuedTo`), `condicionVenta` and the search `q`. An account-wide key may narrow the list to one emisor with `emisorId`. Any other query parameter is a `400` (`urn:sello:problem:unknown-query-parameter`), never ignored. To catch up after missed webhooks, note the time before the first page (the first response's `Date` header is Sello's clock), pass `updatedSince` and page with `nextCursor` until it is `null`; every filter is re-applied on every page. The order and the cursor stay `(created_at, id)`, so a document created long ago and accepted since appears at its creation position. Start the next catch-up from the noted time minus a few minutes: a document that changed while you paged, or whose change committed after a later one, falls inside that overlap. The overlap returns some documents twice, so act on each `(clave, state)` once.