- Webhooks
- Criar webhook
Webhooks
Criar webhook
Cadastra uma URL para receber avisos de eventos de NF-e ou NFS-e
POST
/webhooks
curl --request POST \
--url https://api.treeunfe.com.br/api/v1/webhooks \
--header 'x-api-key: <api-key>' \
--header 'x-api-key: <x_api_key>' \
--header 'Content-Type: application/json' \
--data '{
"url": "<string>",
"eventTypes": "<value>",
"productName": "<string>",
"description": "<string>",
"maxRetries": 123.45,
"auth": "<value>"
}'
curl --request POST \
--url https://api.treeunfe.com.br/api/v1/webhooks \
--header 'x-api-key: <api-key>' \
--header 'x-api-key: <x_api_key>' \
--header 'Content-Type: application/json' \
--data '{
"url": "<string>",
"eventTypes": "<value>",
"productName": "<string>",
"description": "<string>",
"maxRetries": 123.45,
"auth": "<value>"
}'Cadastra uma URL que vai receber um POST da Treeunfe quando os eventos escolhidos acontecerem na empresa. Veja o guia Webhooks com a lista de eventos.
Autenticação
x-api-key
required
string
API Key da empresa.
Body
application/json
url
required
string
URL que recebe os avisos. Use HTTPS.
eventTypes
required
string[]
Eventos que disparam o aviso, por exemplo NFSE_AUTHORIZED ou NFE_CANCELED. Precisam ser do produto informado em productName.
productName
string
Produto: NFE ou NFSE. Padrão: NFE.
description
string
Descrição do webhook.
maxRetries
number
Tentativas de entrega em caso de falha (1 a 10).
auth
object
Como a Treeunfe se autentica na sua URL.
type(string) (obrigatório):NONE,BEARER_TOKEN,CUSTOM_HEADERouQUERY_PARAM.token(string): Token, paraBEARER_TOKEN.key(string): Nome do header ou do parâmetro, paraCUSTOM_HEADEReQUERY_PARAM.value(string): Valor do header ou do parâmetro, paraCUSTOM_HEADEReQUERY_PARAM.
Respostas
| Status | Descrição |
|---|---|
201 | Webhook criado. |
400 | Dados inválidos ou webhook já existente. |
401 | x-api-key ausente ou inválida. |
curl -X POST "https://api.treeunfe.com.br/api/v1/webhooks" \
-H "x-api-key: SUA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://seu-sistema.com.br/webhooks/treeunfe",
"description": "Notas de serviço",
"productName": "NFSE",
"eventTypes": ["NFSE_AUTHORIZED", "NFSE_CANCELED"],
"maxRetries": 5,
"auth": { "type": "BEARER_TOKEN", "token": "SEU_TOKEN" }
}'
curl -X POST "https://api.treeunfe.com.br/api/v1/webhooks" \
-H "x-api-key: SUA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://seu-sistema.com.br/webhooks/treeunfe",
"description": "Notas de serviço",
"productName": "NFSE",
"eventTypes": ["NFSE_AUTHORIZED", "NFSE_CANCELED"],
"maxRetries": 5,
"auth": { "type": "BEARER_TOKEN", "token": "SEU_TOKEN" }
}'
curl --request POST \
--url https://api.treeunfe.com.br/api/v1/webhooks \
--header 'x-api-key: <api-key>' \
--header 'x-api-key: <x_api_key>' \
--header 'Content-Type: application/json' \
--data '{
"url": "<string>",
"eventTypes": "<value>",
"productName": "<string>",
"description": "<string>",
"maxRetries": 123.45,
"auth": "<value>"
}'
curl --request POST \
--url https://api.treeunfe.com.br/api/v1/webhooks \
--header 'x-api-key: <api-key>' \
--header 'x-api-key: <x_api_key>' \
--header 'Content-Type: application/json' \
--data '{
"url": "<string>",
"eventTypes": "<value>",
"productName": "<string>",
"description": "<string>",
"maxRetries": 123.45,
"auth": "<value>"
}'