- Organizations
- Criar organization
Organizations
Criar organization
Cria uma organization cliente sob a Enterprise autenticada
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>"
}'
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>"
}'Cria uma organization cliente sob a Enterprise autenticada.
Com generateApiKey: true e apiKeyOptions, a resposta já traz a API Key em
apiKey.rawKey. Guarde esse valor: ele não é exibido de novo.
Sem generateApiKey (ou com false), a organization nasce sem chave; gere
uma depois em POST /enterprise/organizations/{organizationId}/api-keys.
Autenticação
Envie o header x-enterprise-key.
x-enterprise-key
string
Chave da conta Enterprise (escopo enterprise:manage).
Body
application/json
CNPJCPF
required
string
CNPJ ou CPF só com números. Não pode ser alterado depois.
xNome
required
string
Razão social.
xFant
string
Nome fantasia.
email
required
string
fone
string
IE
string
Inscrição estadual.
address
required
object
Endereço no padrão do leiaute da NF-e.
xLgr(string) (obrigatório): Logradouro.nro(string) (obrigatório): Número.xCpl(string): Complemento.xBairro(string) (obrigatório): Bairro.cMun(integer) (obrigatório): Código IBGE do município (7 dígitos).xMun(string) (obrigatório): Nome do município.UF(string) (obrigatório): Sigla da UF.CEP(string) (obrigatório): CEP só com números (8 dígitos).fone(string): Telefone só com números.
generateApiKey
boolean
Se true, gera uma API Key junto com a organization (requer apiKeyOptions). Padrão: false.
apiKeyOptions
object
name(string) (obrigatório): Nome de identificação da chave.scopes(string) (obrigatório): Escopos separados por vírgula. Valores:nfe:emit,nfe:read,nfse:emit,nfse:read.tpAmb(string) (obrigatório): Ambiente SEFAZ em que a chave pode emitir.expirationPreset(string) (obrigatório): Validade da chave a partir da criação.
Respostas
| Status | Descrição |
|---|---|
201 | Organization criada. |
400 | Body inválido (campo obrigatório ausente, formato incorreto ou campo não permitido). |
401 | Credencial ausente, inválida ou expirada. |
curl -X POST "https://api.treeunfe.com.br/api/v1/enterprise/organizations" \
-H "x-enterprise-key: SUA_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"
}
}
curl -X POST "https://api.treeunfe.com.br/api/v1/enterprise/organizations" \
-H "x-enterprise-key: SUA_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"
}
}'
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>"
}'
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>"
}'{
"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"
}
}