- API Keys
- Create API Key
API Keys
Create API Key
Generates a new API Key for an existing organization
POST
/enterprise/organizations/{organizationId}/api-keys
curl --request POST \
--url https://api.treeunfe.com.br/api/v1/enterprise/organizations/{organizationId}/api-keys \
--header 'x-api-key: <api-key>' \
--header 'x-enterprise-key: <x_enterprise_key>' \
--header 'Content-Type: application/json' \
--data '{
"name": "<string>",
"scopes": "<string>",
"tpAmb": "<string>",
"expirationPreset": "<string>"
}'
curl --request POST \
--url https://api.treeunfe.com.br/api/v1/enterprise/organizations/{organizationId}/api-keys \
--header 'x-api-key: <api-key>' \
--header 'x-enterprise-key: <x_enterprise_key>' \
--header 'Content-Type: application/json' \
--data '{
"name": "<string>",
"scopes": "<string>",
"tpAmb": "<string>",
"expirationPreset": "<string>"
}'Generates a new API Key for an existing organization. Use it for organizations created without a key, or to generate additional keys (for example, one for the sandbox and another for production).
The rawKey only appears in this response.
Authentication
Send the x-enterprise-key header.
x-enterprise-key
string
The Enterprise account’s key (enterprise:manage scope).
Path parameters
organizationId
required
string
The organization’s ID (UUID).
Body
application/json
name
required
string
A name to identify the key.
scopes
required
string
Comma-separated scopes. Values: nfe:emit, nfe:read, nfse:emit, nfse:read.
tpAmb
required
string
SEFAZ environment in which the key can issue. Values: HOMOLOGACAO (sandbox), PRODUCAO (production).
expirationPreset
required
string
How long the key is valid from creation.
Responses
| Status | Description |
|---|---|
201 | Key created. |
400 | Invalid body (missing required field, wrong format, or field not allowed). |
401 | Credential missing, invalid, or expired. |
404 | Resource not found. |
curl -X POST "https://api.treeunfe.com.br/api/v1/enterprise/organizations/7a6b2d8e-4bc3-4a25-a298-adb3ba63f9de/api-keys" \
-H "x-enterprise-key: YOUR_ENTERPRISE_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "integracao-nfe-homolog",
"scopes": "nfe:emit,nfe:read",
"tpAmb": "HOMOLOGACAO",
"expirationPreset": "1y"
}'
{
"keyId": "string",
"rawKey": "string"
}
curl -X POST "https://api.treeunfe.com.br/api/v1/enterprise/organizations/7a6b2d8e-4bc3-4a25-a298-adb3ba63f9de/api-keys" \
-H "x-enterprise-key: YOUR_ENTERPRISE_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "integracao-nfe-homolog",
"scopes": "nfe:emit,nfe:read",
"tpAmb": "HOMOLOGACAO",
"expirationPreset": "1y"
}'
curl --request POST \
--url https://api.treeunfe.com.br/api/v1/enterprise/organizations/{organizationId}/api-keys \
--header 'x-api-key: <api-key>' \
--header 'x-enterprise-key: <x_enterprise_key>' \
--header 'Content-Type: application/json' \
--data '{
"name": "<string>",
"scopes": "<string>",
"tpAmb": "<string>",
"expirationPreset": "<string>"
}'
curl --request POST \
--url https://api.treeunfe.com.br/api/v1/enterprise/organizations/{organizationId}/api-keys \
--header 'x-api-key: <api-key>' \
--header 'x-enterprise-key: <x_enterprise_key>' \
--header 'Content-Type: application/json' \
--data '{
"name": "<string>",
"scopes": "<string>",
"tpAmb": "<string>",
"expirationPreset": "<string>"
}'{
"keyId": "string",
"rawKey": "string"
}