Skip to Content
SelloDeveloper docs
API ReferenceReceived Documents

Ingest a supplier's signed comprobante

Store an inbound supplier comprobante so you (the receptor) can later respond with a Mensaje Receptor. The RECEIVING emisor is resolved from the verified API key's scope (and the optional `Sello-Emisor-Id` header for an account-wide key) — NEVER from the XML, so a key for account A can never file a reception under account B. The response carries the 8-business-day `deadlineAt` to respond. Send the XML raw as `text/xml`/`application/xml`, or wrapped in a JSON envelope `{ "xml": "..." }`. **Idempotency-Key (required).** Keys are case-sensitive and share one namespace per account with `respondReceivedDocument` (issued-document keys are separate). The key is stored with a fingerprint of the resolved emisor, the operation and the extracted XML string, compared verbatim: the same string sent as `text/xml`, `application/xml` or in the JSON envelope is the same request, and any other change to the XML (a byte, a line ending, a trailing newline) is a different one. A fresh ingest answers `201` and stores its answer in the transaction that writes the reception. The same key with the same request replays that stored answer with `200`, the echoed key and `Location`, and its original `status` (`ingested` stays `ingested`). The same key with a different request, emisor or operation answers `409` `idempotency-key-conflict` and changes nothing. A key whose first request is still running answers `409` `idempotency-in-flight` with `Retry-After`. A request that failed stores nothing, so a corrected request may reuse its key. Authentication, scope, ownership and environment refusals are decided before the key. A DIFFERENT key on a supplier clave already ingested for this account is a natural duplicate: `200` with `status: duplicate`, never a second row, and that key then replays the duplicate answer.

POST
/v1/received-documents

Authorization

ApiKeyAuth received-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: received-documents:write

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
Sello-Emisor-Id?string

For 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.

Formatuuid

Request Body

body*string

The raw signed supplier XML (untrusted; hardened parse).

Response Body

Either a replay — this Idempotency-Key already settled for the same request, and its stored answer is returned with its original status — or a natural duplicate — a different key named a supplier clave already ingested for this account (status: duplicate). Nothing is re-inserted.

application/json
  1. response

An ingested supplier document + its Mensaje Receptor deadline. The read (GET /v1/received-documents/{clave}) and each list row (GET /v1/received-documents) return the SAME projection: supplier identity (name + cédula), the invoice issuedAt, the exact-decimal money the row stores (subtotal / taxTotal a.k.a. IVA / total, JSON strings — never floats), the currency, the reception status, the 8-business-day deadlineAt, our Mensaje-Receptor verdict (mrStatus), and the Mensaje Receptor itself (mr) with the amounts it filed once Hacienda accepted it. The create endpoint fills only clave / supplierName / deadlineAt / status; the richer fields are populated by the read + list.

clave*string

The supplier's 50-character clave (or a q-<uuid> quarantine sentinel).

tipo?|

The supplier document type (FE / TE / NC / ND / …), verbatim from ingest.

supplierName?|

The supplier's name parsed from the inbound XML.

supplierCedula?|

The supplier's cédula (identification number) parsed from the inbound XML.

issuedAt?|

The invoice's own issue date (FechaEmision) parsed from the inbound XML.

Formatdate-time
subtotal?|

Subtotal — exact-decimal string (never a float). Null for rows with no parsed amount.

taxTotal?|

Total tax (IVA) — exact-decimal string (never a float).

total?|

Grand total — exact-decimal string (never a float).

currency?string

ISO-4217 currency code (defaults to CRC).

deadlineAt*|

The deadline to respond with a Mensaje Receptor: the 8th business day of the month following the document's emission (Hacienda Art. 10).

Formatdate-time
status*string

The reception status. ingested / duplicate are returned by the create endpoint (fresh vs redelivery); the read endpoint returns the stored reception state.

Value in"ingested""duplicate""received""pending_response""responded_accepted""responded_partial""responded_rejected""quarantined"
mrStatus?|

Our Mensaje-Receptor's Hacienda verdict, once we have responded.

mr?|

The Mensaje Receptor Sello filed for this document, or null before we respond. The read and the list return it; the create endpoint omits it. The two amounts are read from the signed MR XML Sello filed, never from the respond request, and are set only once Hacienda accepted the MR (estado: aceptado); an MR in any other estado carries them as null.

Example Request
curl -X POST 'https://api.sello.cr/v1/received-documents' \  -H 'Idempotency-Key: string' \  -H 'Content-Type: application/json' \  -d '{  "xml": "string"}'
Example Response
{  "clave": "string",  "tipo": "string",  "supplierName": "string",  "supplierCedula": "string",  "issuedAt": "2019-08-24T14:15:22Z",  "subtotal": "string",  "taxTotal": "string",  "total": "string",  "currency": "string",  "deadlineAt": "2019-08-24T14:15:22Z",  "status": "ingested",  "mrStatus": "string",  "mr": {    "clave": "string",    "consecutivo": "string",    "estado": "string",    "montoTotalImpuestoAcreditable": "string",    "montoTotalDeGastoAplicable": "string"  }}

Trigger opt-in email delivery of the comprobante

Enqueues an email carrying the signed XML and the representación gráfica PDF to the document's recipient, on the same at-least-once outbox as every other delivery. The emisor must have OPTED IN to email delivery (422 otherwise — the law mandates delivery of the comprobante, not email; the merchant owns the channel). The recipient defaults to the receptor email in the signed XML; the body may override it. Idempotent per (document, recipient): a replayed trigger reuses the live job (`deduped: true`) and the provider-side idempotency key prevents double-sends, so no Idempotency-Key header is required. Recipient limits (#1402). Addresses are compared after trimming surrounding whitespace and ignoring letter case. One document can be sent to at most 5 distinct addresses: a sixth is refused with `422` (`https://sello.cr/problems/email-document-recipient-limit`), for good. An account can mail a per-account limit of distinct addresses in any rolling 24 hours: a new address past it is refused with `429` (`https://sello.cr/problems/email-daily-recipient-limit`) and `Retry-After`. An address the document already used is never refused by either limit. A refused send queues nothing.

List received (inbox) documents (cursor-paginated)

Return a page of the authenticated account's INBOX — the supplier documents you have ingested — 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); an emisor-pinned key sees only its own emisor's inbox. There is NO cédula parameter — the inbox is key-scoped, never identity-scoped. Filter by reception `status` (e.g. `pending_response` for the docs still awaiting a Mensaje Receptor before their `deadlineAt`), supplier `tipo` and/or the issue date (`issuedFrom` / `issuedTo`). An account-wide key may narrow the inbox to one emisor with `emisorId`. Any other query parameter, `q`, `condicionVenta` and `state` included, is a `400` (`urn:sello:problem:unknown-query-parameter`), never ignored.