Skip to Content
SelloDeveloper docs
API ReferenceReceived Documents

Respond to a received supplier document with a Mensaje Receptor

File OUR signed Mensaje Receptor (MR01 accepted / MR02 partial / MR03 rejected) for a previously ingested supplier comprobante. The engine allocates an MR consecutivo, signs the MR, and enqueues its Hacienda submission on the transactional outbox (filed out of band); the response returns immediately with the generated `mrClave`. 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 body. A rejection (`kind: rejected`) requires a `detalleMensaje`. **Idempotency-Key (required).** Keys are case-sensitive and share one namespace per account with `ingestReceivedDocument`. The key is stored with a fingerprint of the resolved emisor, the operation, the path clave and every field the body supplies, exactly as validated: JSON property order and whitespace do not matter, decimal spelling does (`"100"` and `"100.00"` differ), and an omitted optional field differs from one supplied with its default. A fresh filing answers `201` and stores its answer in the transaction that files it. The same key with the same request replays that stored answer with `200` and the echoed key, its `mrStatus` as it was when the key settled; nothing is signed, numbered, charged or enqueued again. The same key with a different request, target, emisor or operation answers `409` `idempotency-key-conflict` before the target is looked up, 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; an MR number it allocated stays an unused gap. Authentication, scope, ownership and environment refusals are decided before the key. Under a DIFFERENT key the natural rules hold: responding with the same `kind` returns the existing Mensaje Receptor (`200`, same `mrClave`, never a second consecutivo or submission) even if other fields differ, and that key then replays that answer; responding with a different `kind` after a response is a `409` *Not respondable*.

POST
/v1/received-documents/{clave}/respond

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

Path Parameters

clave*string

The supplier's field-composed 50-character clave, as ClaveType ([a-zA-Z0-9]{50,50}) defines it in every v4.4 schema since the 2026-04-22 revision of the annexes. A q-<uuid> quarantine sentinel is deliberately excluded: it is 38 characters, so it can never match, and the respond route refuses a quarantined row by design. This is a THIRD PARTY's clave — ours is composed from a digits-only cedula, and Clave is still ^\d{50}$.

Match^[A-Za-z0-9]{50}$
Length50 <= length <= 50

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

application/json
  1. body

The Mensaje Receptor to file for a received supplier document. kind selects MR01 (accepted) / MR02 (partial) / MR03 (rejected). A rejection requires a detalleMensaje; the acceptance-credit hints are exact-decimal strings (never floats).

kind*string

MR01 accepted / MR02 partial / MR03 rejected.

Value in"accepted""partial""rejected"
detalleMensaje?string

Human-readable message. REQUIRED for a rejection (kind: rejected); optional otherwise.

AT MOST 160 CHARACTERS, which is the v4.4 DetalleMensaje facet and not a Sello preference (#387). A longer reason was accepted here, written into the Mensaje Receptor and signed, and came back schema-rejected — for a receipt-message consecutivo already spent. The count is code points after CRLF is normalised to LF, the same reading every other XSD length in this contract takes.

Length1 <= length <= 160
condicionImpuesto?string

Condición de impuesto (01..05) — acceptances only.

Match^0[1-5]$
montoTotalImpuestoAcreditar?Decimal

An exact decimal as a string — money and quantities are NEVER floats (mirrors the engine's exact-decimal discipline). Plain decimal notation.

AT MOST FIVE fraction digits. Hacienda's amounts are numeric(18,5) and the signed comprobante carries exactly that scale, so a sixth digit is a value Sello cannot sign as sent — it could only round it, and rounding a caller's money silently is the one thing an invoicing engine must not do. A sixth digit is a 422 naming the field, raised before any fiscal number is allocated.

AND AT MOST THIRTEEN INTEGER DIGITS, counted from the first significant one. The magnitude bound is DecimalDineroType's own maxInclusive 9999999999999.99999 — "13 enteros y 5 decimales" (annex p. 50) — and every stored amount is numeric(18,5), which cannot hold a fourteenth integer digit; a larger magnitude is a 422 naming the field, raised before any fiscal number is allocated, not a 500 after one is burnt. Leading zeros are padding, not digits: 000123.45 is 123.45 and passes, while 00010000000000000 is fourteen significant integer digits and is refused. The sign changes nothing: an amount may legitimately be negative, so -9999999999999.99999 passes and -10000000000000 is refused for its magnitude, not its sign. Zero and negative zero pass. The pattern spells this without a lookahead or lookbehind, because Go's RE2 has neither and this schema is generated into SDKs for languages this repo does not build locally. It is the same regex the API validates with, so the contract and the 422 agree. The length cap is a denial-of-service bound, not a business rule: a Hacienda v4.4 amount fits in 32 characters with room to spare.

Match^-?0*\d{1,13}(\.\d{1,5})?$
Lengthlength <= 32
montoTotalDeGastoAplicable?Decimal

An exact decimal as a string — money and quantities are NEVER floats (mirrors the engine's exact-decimal discipline). Plain decimal notation.

AT MOST FIVE fraction digits. Hacienda's amounts are numeric(18,5) and the signed comprobante carries exactly that scale, so a sixth digit is a value Sello cannot sign as sent — it could only round it, and rounding a caller's money silently is the one thing an invoicing engine must not do. A sixth digit is a 422 naming the field, raised before any fiscal number is allocated.

AND AT MOST THIRTEEN INTEGER DIGITS, counted from the first significant one. The magnitude bound is DecimalDineroType's own maxInclusive 9999999999999.99999 — "13 enteros y 5 decimales" (annex p. 50) — and every stored amount is numeric(18,5), which cannot hold a fourteenth integer digit; a larger magnitude is a 422 naming the field, raised before any fiscal number is allocated, not a 500 after one is burnt. Leading zeros are padding, not digits: 000123.45 is 123.45 and passes, while 00010000000000000 is fourteen significant integer digits and is refused. The sign changes nothing: an amount may legitimately be negative, so -9999999999999.99999 passes and -10000000000000 is refused for its magnitude, not its sign. Zero and negative zero pass. The pattern spells this without a lookahead or lookbehind, because Go's RE2 has neither and this schema is generated into SDKs for languages this repo does not build locally. It is the same regex the API validates with, so the contract and the 422 agree. The length cap is a denial-of-service bound, not a business rule: a Hacienda v4.4 amount fits in 32 characters with room to spare.

Match^-?0*\d{1,13}(\.\d{1,5})?$
Lengthlength <= 32

Response Body

Either a replay — this Idempotency-Key already settled for the same request, and its stored answer is returned — or a natural replay — a different key asked for the kind already filed for this received document, and the existing Mensaje Receptor is returned.

application/json
  1. response

The filed Mensaje Receptor + its (pending) Hacienda delivery status.

clave*string

The supplier's 50-character clave this MR responds to.

mrClave*string

OUR generated 50-digit Mensaje Receptor clave.

status*string

The received document's reception status after responding.

Value in"responded_accepted""responded_partial""responded_rejected"
mrStatus*string

The Mensaje Receptor's delivery status. pending until the worker files it and Hacienda answers.

Example Request
curl -X POST 'https://api.sello.cr/v1/received-documents/stringstringstringstringstringstringstringstringst/respond' \  -H 'Idempotency-Key: string' \  -H 'Content-Type: application/json' \  -d '{  "kind": "accepted"}'
Example Response
{  "clave": "string",  "mrClave": "string",  "status": "responded_accepted",  "mrStatus": "string"}