1. Organizations
  2. Create organization
POST
/enterprise/organizations
curl --request POST \
     --url https://api.treeunfe.com.br/api/v1/enterprise/organizations \
     --header 'x-api-key: <api-key>' \
     --header 'x-enterprise-key: <x_enterprise_key>' \
     --header 'Content-Type: application/json' \
     --data '{
  "CNPJCPF": "<string>",
  "xNome": "<string>",
  "xFant": "<string>",
  "email": "<string>",
  "fone": "<string>",
  "IE": "<string>",
  "address": "<value>",
  "generateApiKey": true,
  "apiKeyOptions": "<value>"
}'

Creates a customer organization under the authenticated Enterprise.

With generateApiKey: true and apiKeyOptions, the response already includes the API Key in apiKey.rawKey. Store this value: it is not shown again. Without generateApiKey (or with false), the organization is created without a key; generate one later with POST /enterprise/organizations/{organizationId}/api-keys.

​
Authentication

Send the x-enterprise-key header.

x-enterprise-key
string

The Enterprise account’s key (enterprise:manage scope).

​
Body

application/json

CNPJCPF
required
string

CNPJ or CPF, digits only. Cannot be changed later.

xNome
required
string

Legal name.

xFant
string

Trade name.

email
required
string
fone
string
IE
string

State registration.

address
required
object

Address following the NF-e layout.

  • xLgr (string) (required): Street.
  • nro (string) (required): Number.
  • xCpl (string): Address line 2.
  • xBairro (string) (required): Neighborhood.
  • cMun (integer) (required): The municipality’s IBGE code (7 digits).
  • xMun (string) (required): Municipality name.
  • UF (string) (required): State abbreviation.
  • CEP (string) (required): Postal code (CEP), digits only (8 digits).
  • fone (string): Phone number, digits only.
generateApiKey
boolean

If true, generates an API Key together with the organization (requires apiKeyOptions). Default: false.

apiKeyOptions
object
  • name (string) (required): A name to identify the key.
  • scopes (string) (required): Comma-separated scopes. Values: nfe:emit, nfe:read, nfse:emit, nfse:read.
  • tpAmb (string) (required): SEFAZ environment in which the key can issue.
  • expirationPreset (string) (required): How long the key is valid from creation.

​
Responses

StatusDescription
201Organization created.
400Invalid body (missing required field, wrong format, or field not allowed).
401Credential missing, invalid, or expired.
curl -X POST "https://api.treeunfe.com.br/api/v1/enterprise/organizations" \
  -H "x-enterprise-key: YOUR_ENTERPRISE_KEY" \
  -H "Content-Type: application/json" \
  -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-inicial-organization",
      "scopes": "nfe:emit,nfe:read,nfse:emit,nfse:read",
      "tpAmb": "HOMOLOGACAO",
      "expirationPreset": "1y"
    }
  }'
{
  "organization": {
    "id": "string",
    "CNPJCPF": "string",
    "xNome": "string",
    "xFant": "string",
    "email": "string",
    "fone": "string",
    "IE": "string",
    "address": {
      "xLgr": "Rua das Palmeiras",
      "nro": "456",
      "xCpl": "string",
      "xBairro": "Centro",
      "cMun": 3550308,
      "xMun": "São Paulo",
      "UF": "SP",
      "CEP": "01002000",
      "fone": "string"
    },
    "isActive": true
  },
  "apiKey": {
    "keyId": "string",
    "rawKey": "string"
  }
}