1. Guides
  2. Registering organizations

An organization is an issuing company in your Enterprise account. The routes on this page use the Enterprise key. Except for Create, also send x-organization-id.

​
Create

POST /enterprise/organizations

{
  "CNPJCPF": "12345678000195",
  "xNome": "Cliente Exemplo LTDA",
  "xFant": "Cliente Exemplo",
  "email": "fiscal@cliente-exemplo.com.br",
  "fone": "+5511999887755",
  "IE": "123456789",
  "address": {
    "xLgr": "Rua das Palmeiras",
    "nro": "456",
    "xBairro": "Centro",
    "cMun": 3550308,
    "xMun": "São Paulo",
    "UF": "SP",
    "CEP": "01002000"
  }
}
FieldDescription
CNPJCPFCNPJ or CPF (Brazilian company or individual tax ID), digits only. Cannot be changed later.
xNome / xFantLegal name and trade name.
email, fone, IEContact details and state registration (IE).
addressAddress. cMun is the municipality’s IBGE code (7 digits).

The response (201) includes the organization. Store the organization.id: it goes in the x-organization-id header of the other routes.

​
Edit

PATCH /enterprise/organizations/{organizationId}

Send only the fields that changed:

{ "xNome": "Cliente Exemplo LTDA - Matriz" }

Accepted fields: xNome, xFant, email, fone, IE, address, and isActive.

The body is strict. Any field outside this list returns 400. Sending CNPJCPF, even with the current value, returns 400 CNPJ não pode ser alterado (“CNPJ cannot be changed”).

​
Deactivate

{ "isActive": false }

While the organization is inactive, calls with its id receive 403 Organization is inactive. Send isActive: true to reactivate it.

​
Fiscal configuration

Before issuing, the organization needs its NF-e settings and issuing rules. There are two paths:

  • Default rules of the tax engine: the company uses Treeunfe’s default rules, with nothing to register.
  • Rule-sharing link: you generate a link and send it to the company. Through the link, the company fills in its own fiscal configuration and registers its issuing rules, each with an optional identifier (for example, REM01).

In both cases, the Treeunfe engine calculates the taxes. For an item to use a specific rule, such as the shipment rule, send the rule’s identifier or ID in taxRuleId. See how the issuing rule is chosen.

ActionEndpoint
Create linkPOST /bff/enterprise-group/organizations/{organizationId}/fiscal-config-invites
List linksGET /bff/enterprise-group/organizations/{organizationId}/fiscal-config-invites

​
Digital certificate

The organization also needs an A1 certificate (.pfx). Send the Enterprise key and the company’s x-organization-id:

ActionEndpoint
UploadPOST /certificates/upload (multipart/form-data with file and password)
Get the current oneGET /certificates/current
DeleteDELETE /certificates/{certificateId}
curl -X POST https://api.treeunfe.com.br/api/v1/certificates/upload \
  -H "x-enterprise-key: YOUR_ENTERPRISE_KEY" \
  -H "x-organization-id: ORGANIZATION_ID" \
  -F "file=@certificado.pfx" \
  -F "password=CERTIFICATE_PASSWORD"