1. API Keys
  2. Create API Key
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>"
}'

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

StatusDescription
201Key created.
400Invalid body (missing required field, wrong format, or field not allowed).
401Credential missing, invalid, or expired.
404Resource 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"
}