Skip to Content
SelloDeveloper docs
API ReferenceConnect

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.

POST
/connect/emisores/{emisorId}/credential-grants

Authorization

headerAuthorizationBearer <token>

A connector's platform credential, sent as a bearer token: Authorization: Bearer sello_platform_<8 hex>_<secret>. An operator registers the connector and issues its credentials; Sello stores only their hash and shows the plaintext once. It authenticates the /connect operations that name this scheme and nothing else: /v1 and /reference refuse it with 401. A revoked credential, or one whose connector is disabled, is refused with 401.

Path Parameters

emisorId*string

The emisor whose credentials the grant may write.

Response Body

The grant. The token is returned once.

application/json
  1. response

A single-use credential upload grant. token is the only copy of the grant's secret; Sello stores its hash.

uploadUrl*string

Where the browser posts the credential form. Never contains the token.

Formaturi
token*string

The grant token, sello_grant_…. Send it as the bearer.

expiresAt*string

The mint time plus exactly 600 seconds.

Formatdate-time
Example Request
curl -X POST 'https://api.sello.cr/connect/emisores/string/credential-grants'
Example Response
{  "uploadUrl": "http://example.com",  "token": "string",  "expiresAt": "2019-08-24T14:15:22Z"}

Provision a company for a connector

Creates, in one transaction, an account (with its organization and no member), one emisor in the requested `environment`, and one company key pinned to that emisor. The key holds the five default permissions plus `credentials:read` and `credentials:write`; it is a `sello_live_` key for a production emisor and a `sello_test_` key for a sandbox one. The response is the only place its plaintext appears. The connector comes from the platform credential, never from the body. The provisioning identity is (connector, `companyId`, `environment`): sandbox and production are separate accounts, and `companyId` is compared exactly as sent (no trim, no case folding). The emisor's Hacienda endpoints and client id come from the deployment. A REPLAY (same identity, same details) answers `200` with the same `accountId` and `emisorId` and a NEW key, and revokes the key the previous answer returned: save the newest key. The same identity with different details answers `409` `https://sello.cr/problems/provisioning-conflict` and changes nothing. Requests for one identity run one at a time. `production` needs a production plan on the connector (otherwise `409` `https://sello.cr/problems/production-not-enabled`), an explicit `emisor.numberingMigrating`, and the deployment's published production endpoints (otherwise `503` `https://sello.cr/problems/production-endpoints-not-published`). Nothing is written on any refusal.

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.