Skip to content

Set the tenant's active environment

PATCH
/v1/tenants/{tenantId}/credentials/active-environment
curl --request PATCH \
--url https://api.emite.cr/v1/tenants/example/credentials/active-environment \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "environment": "sandbox" }'

Switches the environment the company works in: documents created from then on in a member's session are issued there, with that environment's credentials. A document keeps the environment it was created in, and an API key stays bound to its own. Rejects with 422 TARGET_ENVIRONMENT_NOT_CONFIGURED if the target environment has no uploaded credentials.

tenantId
required
string
Media typeapplication/json
object
environment
required

Where the company works from now on: sandbox (Hacienda's test environment, no fiscal value) or production (real documents). Its credentials must already be uploaded (422 TARGET_ENVIRONMENT_NOT_CONFIGURED). It applies to the members' sessions — an API key stays bound to its own environment — and a document keeps the environment it was created in.

string
Allowed values: sandbox production
Example
sandbox
Media typeapplication/json
object
activeEnvironment
required

The company's active environment, as it now is.

string
Allowed values: sandbox production
Example
{
"activeEnvironment": "sandbox"
}

Missing or invalid JWT / API key

:tenantId is not the caller's company, or insufficient scope — credentials:* is never granted to an API key.

Target environment has no credentials configured.