- Getting started
- Authentication
Getting started
Authentication
The Enterprise key, its permissions, and the issuing company header.
Every route uses a single credential: the Enterprise key, sent in the x-enterprise-key header. On the routes of an issuing company, also send x-organization-id to say which company the operation applies to. The URL does not change between sandbox and production. The environment is on the key.
https://api.treeunfe.com.br/api/v1
| Header | When to send it |
|---|---|
x-enterprise-key: <key> | On every route. |
x-organization-id: <id> | On every route except Create organization. |
In your program, read both values from environment variables and send the headers on every company call:
curl https://api.treeunfe.com.br/api/v1/customers \
-H "x-enterprise-key: $TREEUNFE_ENTERPRISE_KEY" \
-H "x-organization-id: $TREEUNFE_ORGANIZATION_ID"
Generating the key
The key is generated in the Treeunfe dashboard. When you create it, you choose:
- Permissions: the actions the key can perform. See Permissions.
- Environment: sandbox or production. See Environment.
The Enterprise key works for every issuing company in the account, within the chosen permissions. Keep it in your backend, in the environment variable. Do not put it in apps, in the browser, or in source repositories.
To issue with an agent, use the Enterprise MCP. The agent signs in with the Enterprise account, and the environment is chosen in that login.
Permissions
Select only the permissions your integration needs. A call without the route’s permission receives 403.
| Group | Actions |
|---|---|
| Digital certificate | Upload |
| Customers | Create, read, edit, and delete |
| Products | Create, read, edit, and delete |
| Carriers | Create, read, edit, and delete |
| Accountants | Create, read, edit, and delete |
| Tax rules | Create, read, edit, and delete |
| Invoices | Issue, send, read, and cancel NF-e |
Environment
The invoice’s environment comes from the key: a sandbox key issues in the sandbox (homologação) and a production key in production. Do not send the environment in the payload.
Integrate and test with a sandbox key. Generate the production key only when you go live.
Issuing company
x-organization-id is the organization’s id, returned by Create organization. With the same key, you switch companies just by changing this header.
If the organization is inactive, calls with its id receive 403 Organization is inactive.