Partial update of ATV credentials (no .p12 change)
const url = 'https://api.emite.cr/v1/tenants/example/credentials/sandbox';const options = { method: 'PATCH', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"atvUsername":"cpf-12-3456-789012@stag.comprobanteselectronicos.go.cr","atvPassword":"AtvP4ssw0rd!","atvClientId":"api-stag","atvClientSecret":"optional-client-secret"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url https://api.emite.cr/v1/tenants/example/credentials/sandbox \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "atvUsername": "cpf-12-3456-789012@stag.comprobanteselectronicos.go.cr", "atvPassword": "AtvP4ssw0rd!", "atvClientId": "api-stag", "atvClientSecret": "optional-client-secret" }'Update individual ATV fields without re-uploading the certificate. Sensitive fields (atvPassword, atvClientSecret) are write-only — omit to keep the existing value. Saving credentials that Hacienda had refused clears the refusal, and the documents that waited for them go to Hacienda on their own.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
New ATV user; omit it to keep the stored one. A new user in Hacienda's usual form must embed the company's cédula (400 ATV_USER_IDENTIFICATION_MISMATCH). Whatever is sent is merged with what is stored and tried against the IdP before saving (400 ATV_CREDENTIALS_REJECTED when Hacienda refuses it).
Example
cpf-12-3456-789012@stag.comprobanteselectronicos.go.crNew password of the ATV user; omit it to keep the stored one.
Example
AtvP4ssw0rd!New IdP client id (api-stag for sandbox, api-prod for production); omit it to keep the stored one.
Example
api-stagNew IdP client secret; omit it to keep the stored one.
Example
optional-client-secretResponses
Section titled “Responses”object
A fixed confirmation, in English: Credentials uploaded successfully after PUT, Certificate replaced after PUT …/certificate, ATV credentials updated after PATCH. To read what is stored, use GET …/credentials.
Example
{ "message": "Credentials uploaded successfully"}Missing or invalid JWT / API key
:tenantId is not the caller's company, or insufficient scope — credentials:* is never granted to an API key.