Skip to Content
SelloDeveloper docs
API ReferenceConnect

Upload an emisor's credentials with a grant

Sent by the customer's browser to the `uploadUrl` of a grant, with `Authorization: Bearer <grant token>` and an `Origin` header. No API key, cookie or session is needed; cookies are ignored. The body is `multipart/form-data` with exactly four parts: `p12`, `pin`, `haciendaUsername` and `haciendaPassword`. Values are not trimmed. Sello checks, in this order: the token (`401` `https://sello.cr/problems/invalid-grant` for a missing, malformed, unknown or expired token; nothing consumed); then consumes the grant (a grant already used answers `429` `https://sello.cr/problems/grant-already-used` with `Retry-After`; mint a new one); then counts the attempt against the emisor (ten consuming attempts per emisor per fixed ten-minute window, then `429` with `Retry-After`, ahead of the origin and target checks); then the `Origin` (`403` `https://sello.cr/problems/origin-not-allowed`); then the path emisor (`403` `https://sello.cr/problems/grant-emisor-mismatch`); then the form; then the certificate and PIN; then one uncached Hacienda login with the submitted user and password against the emisor's own token endpoint and client id. Only after all of that are the four values stored, together, in one commit. Every refusal after the token check leaves the grant consumed: a grant allows one attempt. A failed upload leaves the previously stored credential set unchanged; a renewal is the same call. The answer shows nothing of the stored set. Preflight: `OPTIONS` on this path from an origin of an active connector answers `204` with `Access-Control-Allow-Origin`, `Access-Control-Allow-Methods: POST`, `Access-Control-Allow-Headers: Authorization, Content-Type` and `Access-Control-Max-Age: 600`, and consumes nothing; any other origin answers `403` with no CORS header. A POST from such an origin carries `Access-Control-Allow-Origin` on success and on refusal.

POST
/connect/emisores/{emisorId}/credentials

Authorization

UploadGrantAuth
headerAuthorizationBearer <token>

A single-use credential upload grant token, sent as a bearer token by the customer's browser: Authorization: Bearer sello_grant_<secret>. Minted by mintCredentialUploadGrant, it lives 600 seconds and authenticates only redeemCredentialUploadGrant for its own emisor, one attempt. It reads nothing: every other operation refuses it with 401.

Path Parameters

emisorId*string

The emisor the grant was minted for.

Header Parameters

Origin*string

The browser origin. It must be an allowed origin of the grant's connector (or, for a grant on an account no connector created, of any active connector).

Request Body

multipart/form-data
  1. body

Exactly these four parts, each present once and non-empty. Any other part answers 422. Values are not trimmed.

p12*file

The llave criptográfica (.p12) file.

Formatbinary
pin*string

The certificate PIN.

Length1 <= length
haciendaUsername*string

The Hacienda reception API user.

Length1 <= length
haciendaPassword*string

The Hacienda reception API password.

Length1 <= length

Response Body

The four values were stored together.

application/json
  1. response

The four values were stored together. Nothing of the stored set is returned.

emisorId*string
Formatuuid
result*"stored"
Value in"stored"
certificateExpiresAt*string

The expiry of the stored certificate.

Formatdate-time
Example Request
curl -X POST 'https://api.sello.cr/connect/emisores/string/credentials' \  -H 'Origin: string' \  -F 'p12=string' \  -F 'pin=string' \  -F 'haciendaUsername=string' \  -F 'haciendaPassword=string'
Example Response
{  "emisorId": "ffed7f26-5af9-4c47-8187-286731b1e596",  "result": "stored",  "certificateExpiresAt": "2019-08-24T14:15:22Z"}

Mint a single-use credential upload grant

Mints a grant that lets a browser upload one emisor's credential set (the .p12 certificate, its PIN and the Hacienda user and password) straight to Sello, once. The request has no body; the emisor is the path parameter. Two credentials may mint. A connector's platform credential (`ConnectorAuth`) mints only for an emisor its connector provisioned; any other emisor answers `404`. A company key (`ApiKeyAuth`) must be pinned to this emisor and hold `credentials:write`; an account-wide key or a key pinned to another emisor answers `403` `https://sello.cr/problems/emisor-out-of-scope`, and a `test` key on a production emisor answers `403` `Wrong key environment`. The answer is the only place the grant token appears; Sello stores its SHA-256 hash. The grant lives exactly 600 seconds, writes the credentials of this one emisor only and reads nothing. `uploadUrl` is the deployment's public API base (`SELLO_PUBLIC_API_URL`) with `/connect/emisores/{emisorId}/credentials` appended; it never contains the token. Minting changes no other grant: several unused grants of one emisor stay usable until each expires or is consumed. Ten mints per emisor per fixed ten-minute window; the eleventh answers `429` and creates no grant.

Read an emisor's credential status

Reports whether the emisor has a complete credential set stored (the certificate, its PIN, the Hacienda user and password, the emisor's Hacienda endpoints and client id, and the certificate's expiry) and how close the certificate is to expiring. This reports what is stored, not whether Hacienda accepts the login now: the read decrypts nothing and calls no Hacienda service. `status` is `none` when any of those values is missing; otherwise `expired` when the certificate's expiry is at or before now; otherwise `expiring` when it is within 30 days of now; otherwise `valid`. `certificateExpiresAt` is the stored expiry whenever one is stored, `none` included, and null otherwise. Only a company key (`ApiKeyAuth`) pinned to this emisor and holding `credentials:read` may read. An account-wide key or a key pinned to another emisor answers `403` `https://sello.cr/problems/emisor-out-of-scope`, and a `test` key on a production emisor answers `403` `Wrong key environment`. A suspended or closed account may still read. A platform credential and an upload grant token are refused with `401`.