Upload .p12 + PIN + ATV credentials for an environment
const url = 'https://api.emite.cr/v1/partner/tenants/example/credentials/example';const form = new FormData();form.append('pin', '1234');form.append('atvUsername', 'cpf-12-3456-789012@stag.comprobanteselectronicos.go.cr');form.append('atvPassword', 'AtvP4ssw0rd!');form.append('atvClientId', 'api-stag');form.append('atvClientSecret', 'optional-client-secret');
const options = {method: 'PUT'};
options.body = form;
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PUT \ --url https://api.emite.cr/v1/partner/tenants/example/credentials/example \ --header 'Content-Type: multipart/form-data' \ --form pin=1234 \ --form atvUsername=cpf-12-3456-789012@stag.comprobanteselectronicos.go.cr \ --form 'atvPassword=AtvP4ssw0rd!' \ --form atvClientId=api-stag \ --form atvClientSecret=optional-client-secretMultipart: the .p12 file in the p12 field (400 P12_FILE_REQUIRED without it) plus pin, atvUsername, atvPassword, atvClientId and optionally atvClientSecret; environment is sandbox or production (400 ENVIRONMENT_INVALID). Nothing is stored unless the certificate belongs to the company (400 CERT_IDENTIFICATION_MISMATCH), the ATV user names the same identification (400 ATV_USER_IDENTIFICATION_MISMATCH) and Hacienda's identity provider accepts the user and password (400 ATV_CREDENTIALS_REJECTED; 502 when it does not answer). Replaces whatever that environment had; if Hacienda had refused the previous ones, the documents that waited for them go out again. Secrets pass through in transit only (encrypted at rest, never logged, never returned). Production uploads require the partner app to have production access (403 PARTNER_PRODUCTION_NOT_ENABLED).
Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Header Parameters
Section titled “Header Parameters”Partner app credential (ecp_*)
Request Bodyrequired
Section titled “Request Bodyrequired”object
PIN of the .p12 signing certificate uploaded with it. The certificate must open with it (400 CERTIFICATE_INVALID otherwise) and belong to the company's own identification (400 CERT_IDENTIFICATION_MISMATCH). Stored encrypted, never returned.
Example
1234The ATV user Hacienda issued for this environment. In Hacienda's usual form (cp<type>-<cédula>@…) the cédula must be the company's (400 ATV_USER_IDENTIFICATION_MISMATCH). The user, password and client are tried against the environment's Hacienda IdP before anything is saved: 400 ATV_CREDENTIALS_REJECTED when Hacienda refuses them.
Example
cpf-12-3456-789012@stag.comprobanteselectronicos.go.crPassword of that ATV user. Stored encrypted, never returned.
Example
AtvP4ssw0rd!Client id of Hacienda's IdP for the environment: api-stag for sandbox, api-prod for production.
Example
api-stagClient secret for that IdP client, when there is one; omitted, an empty secret is sent. Stored encrypted, never returned.
Example
optional-client-secretResponses
Section titled “Responses”object
A fixed English confirmation — Credentials stored or Logo stored. The 200 status is what confirms it; nothing in the body needs parsing.
Example
{ "message": "Credentials stored"}