1. Getting started
  2. Quickstart

This guide is for your company’s system to call the API. The URL is always the same:

https://api.treeunfe.com.br/api/v1

Sandbox (homologação) and production do not change the host. Each API Key is created in one environment, and the program only issues in that environment.

To issue by talking to Claude, Cursor, or another agent, use the MCP. That connection operates in production.

1

Check the issuer app

In the Treeunfe issuer app, check that the company has a valid A1 certificate and that the NF-e (or NFS-e) settings are filled in for the sandbox.

The certificate can also be uploaded through the API. See Upload A1 certificate.

2

Generate a sandbox API Key

In Integrações, click Nova, choose Api-Key, and select the HOMOLOGACAO environment. See Authentication.

3

Put the key in your program

Store the key in a backend environment variable, for example TREEUNFE_API_KEY, and send the x-api-key header on every call. The first call can be the company that owns the key:

curl -X GET "https://api.treeunfe.com.br/api/v1/organizations/current" \
  -H "x-api-key: $TREEUNFE_API_KEY" \
  -H "Accept: application/json"

401 means the key is missing, invalid, or expired. See Errors.

4

Check the checklist and the tax rules

With the key, read the current company to get the id, then the NF-e checklist. It shows whether the certificate, the series and number settings, or a tax rule is missing.

Calculated issuance uses the company’s tax rules. If there is no rule of your own for the NCM, the system’s default rules apply.

5

Register the customer (optional)

To reuse the recipient on several invoices, register the customer first. With a CNPJ, the document and the state-registration indicator are enough. See Records.

6

Issue the NF-e

Send the invoice with calculateTaxes: true (Payload Inteligente). Send only the recipient’s document and each item’s code, quantity, and price; Treeunfe completes the invoice and calculates the taxes. Then use Get NF-e to check whether it was authorized.

curl -X POST https://api.treeunfe.com.br/api/v1/nfe \
  -H "x-api-key: $TREEUNFE_API_KEY" \
  -H "Content-Type: application/json" \
  -d @nota.json

The full payload is in Issuing NF-e. When you go live, generate another key with the PRODUCAO environment and point TREEUNFE_API_KEY at it. The URL stays the same.

​
Issuing NFS-e?

The first steps are the same: a HOMOLOGACAO key in the program and the x-api-key header. Then check the NFS-e settings, choose the service code, and issue:

curl -X POST https://api.treeunfe.com.br/api/v1/nfse \
  -H "x-api-key: $TREEUNFE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "tomadorCnpj": "12345678000195", "cTribNac": "010501", "vServ": 230 }'

See Issuing NFS-e.