1. Getting started
  2. Quickstart

This guide takes you from creating the customer to the first authorized NF-e in the sandbox (homologação, SEFAZ’s test environment).

You need an x-enterprise-key for your Enterprise account. If you don’t have one yet, contact support.

1

Create the organization with an API Key

Register the customer and generate a sandbox key in the same request.

curl -X POST https://api.treeunfe.com.br/api/v1/enterprise/organizations \
  -H "Content-Type: application/json" \
  -H "x-enterprise-key: YOUR_ENTERPRISE_KEY" \
  -d '{
    "CNPJCPF": "12345678000195",
    "xNome": "CLIENTE EXEMPLO LTDA",
    "xFant": "CLIENTE EXEMPLO",
    "email": "fiscal@cliente-exemplo.com.br",
    "fone": "44999990000",
    "IE": "9071311225",
    "address": {
      "xLgr": "Avenida Exemplo", "nro": "5145", "xBairro": "Zona 07",
      "cMun": 4115200, "xMun": "MARINGA", "UF": "PR", "CEP": "87020035"
    },
    "generateApiKey": true,
    "apiKeyOptions": {
      "name": "chave-homologacao",
      "scopes": "nfe:emit,nfe:read",
      "tpAmb": "HOMOLOGACAO",
      "expirationPreset": "1y"
    }
  }'

The response includes organization.id and apiKey.rawKey.

The rawKey only appears in this response. Store it in a secrets vault before moving on.

2

Upload the digital certificate

The organization needs an A1 certificate to sign the invoices.

curl -X POST https://api.treeunfe.com.br/api/v1/certificates/upload \
  -H "x-api-key: ORGANIZATION_RAW_KEY" \
  -F "file=@certificado.pfx" \
  -F "password=CERTIFICATE_PASSWORD"
3

Ask the customer to fill in the fiscal configuration

Generate a link and send it to the customer. There, they fill in the company’s NF-e settings.

curl -X POST https://api.treeunfe.com.br/api/v1/bff/enterprise-group/organizations/ORGANIZATION_ID/fiscal-config-invites \
  -H "x-enterprise-key: YOUR_ENTERPRISE_KEY"
4

Issue the NF-e

Send the invoice with the sandbox key and calculateTaxes: true so Treeunfe calculates the taxes. The full payload is in Issuing NF-e.

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

If the invoice is authorized, the response has outcome: "SUCCESS", the chaveAcesso (access key), and the protocolo (protocol number).

​
Next steps