API BCE referencia de webhooks: crear y gestionar endpoints
Referencia de webhooks de API BCE: crear, listar, modificar y eliminar un webhook, gestionar sus suscripciones, renovar el secreto HMAC y leer el registro.
Endpoints del recurso API de Webhooks. Todas las llamadas requieren autenticación y devuelven el envelope JSON estándar.
URL base: https://companybelgium.be/api/v2 · Autenticación
List all webhooks#
Every webhook registered for the authenticated company.
Este endpoint no recibe parámetros.
Solicitud
curl https://companybelgium.be/api/v2/webhooks \
-H "X-API-Key: $API_BCE_KEY" \
-H "X-API-Secret: $API_BCE_SECRET"Respuesta
{
"success": true,
"data": [
{
"id": "...",
"name": "Prod listener",
"url": "https://example.be/hooks/bce",
"disabled": false,
"createdAt": "...",
"lastTriggeredAt": null,
"subscriptionCount": 1
}
],
"timestamp": "..."
}▶ Probar esta solicitud
Create a webhook#
Registers an outbound webhook. The HMAC signing secret is returned only once, in this response. Store it securely.
Cuerpo de la solicitud
{
"name": "Prod listener",
"url": "https://example.be/hooks/bce",
"entityNumbers": [
"1033.022.383"
]
}Solicitud
curl -X POST https://companybelgium.be/api/v2/webhook \
-H "X-API-Key: $API_BCE_KEY" \
-H "X-API-Secret: $API_BCE_SECRET" \
-H "Content-Type: application/json" \
-d '{"name":"Prod listener","url":"https://example.be/hooks/bce","entityNumbers":["1033.022.383"]}'Respuesta
{
"success": true,
"data": {
"id": "...",
"name": "Prod listener",
"url": "https://example.be/hooks/bce",
"hmacSecret": "...",
"createdAt": "..."
},
"timestamp": "..."
}Retrieve a webhook#
A single webhook by id.
Parámetros
| Nombre | En/Tipo | Requerido | Descripción |
|---|---|---|---|
id | path string | Requerido | Webhook id. |
Solicitud
curl https://companybelgium.be/api/v2/webhook/WEBHOOK_ID \
-H "X-API-Key: $API_BCE_KEY" \
-H "X-API-Secret: $API_BCE_SECRET"Respuesta
{
"success": true,
"data": {
"id": "...",
"name": "Prod listener",
"url": "https://example.be/hooks/bce",
"disabled": false,
"createdAt": "...",
"lastTriggeredAt": null
},
"timestamp": "..."
}▶ Probar esta solicitud
Update a webhook#
Update name, url or disabled flag.
Parámetros
| Nombre | En/Tipo | Requerido | Descripción |
|---|---|---|---|
id | path string | Requerido | Webhook id. |
Cuerpo de la solicitud
{
"name": "Prod listener (paused)",
"disabled": true
}Solicitud
curl -X PUT https://companybelgium.be/api/v2/webhook/WEBHOOK_ID \
-H "X-API-Key: $API_BCE_KEY" \
-H "X-API-Secret: $API_BCE_SECRET" \
-H "Content-Type: application/json" \
-d '{"name":"Prod listener (paused)","disabled":true}'Respuesta
{
"success": true,
"data": {
"id": "...",
"name": "Prod listener (paused)",
"url": "https://example.be/hooks/bce",
"disabled": true,
"createdAt": "...",
"lastTriggeredAt": null
},
"timestamp": "..."
}Delete a webhook#
Deletes the webhook and cascades its subscriptions and delivery events.
Parámetros
| Nombre | En/Tipo | Requerido | Descripción |
|---|---|---|---|
id | path string | Requerido | Webhook id. |
Solicitud
curl -X DELETE https://companybelgium.be/api/v2/webhook/WEBHOOK_ID \
-H "X-API-Key: $API_BCE_KEY" \
-H "X-API-Secret: $API_BCE_SECRET"Respuesta
{
"success": true,
"data": {
"id": "...",
"deleted": true
},
"timestamp": "..."
}Rotate the HMAC signing secret#
Generates a new HMAC secret, returned only once. The old secret stops being valid immediately.
Parámetros
| Nombre | En/Tipo | Requerido | Descripción |
|---|---|---|---|
id | path string | Requerido | Webhook id. |
Solicitud
curl -X PATCH https://companybelgium.be/api/v2/webhook/WEBHOOK_ID/hmac-secret \
-H "X-API-Key: $API_BCE_KEY" \
-H "X-API-Secret: $API_BCE_SECRET"Respuesta
{
"success": true,
"data": {
"id": "...",
"hmacSecret": "..."
},
"timestamp": "..."
}Send a test delivery#
Manually triggers a test event so you can verify your endpoint and signature handling.
Parámetros
| Nombre | En/Tipo | Requerido | Descripción |
|---|---|---|---|
id | path string | Requerido | Webhook id. |
Solicitud
curl -X POST https://companybelgium.be/api/v2/webhook/WEBHOOK_ID/trigger \
-H "X-API-Key: $API_BCE_KEY" \
-H "X-API-Secret: $API_BCE_SECRET"Respuesta
{
"success": true,
"data": {
"id": "...",
"triggered": true
},
"timestamp": "..."
}List subscribed entity numbers#
Entity numbers this webhook is subscribed to.
Parámetros
| Nombre | En/Tipo | Requerido | Descripción |
|---|---|---|---|
id | path string | Requerido | Webhook id. |
Solicitud
curl https://companybelgium.be/api/v2/webhook/WEBHOOK_ID/subscriptions \
-H "X-API-Key: $API_BCE_KEY" \
-H "X-API-Secret: $API_BCE_SECRET"Respuesta
{
"success": true,
"data": [
{
"entityNumber": "1033022383",
"entityType": null,
"createdAt": "..."
}
],
"timestamp": "..."
}▶ Probar esta solicitud
Add entity subscriptions#
Subscribe the webhook to one or more enterprise/establishment numbers.
Parámetros
| Nombre | En/Tipo | Requerido | Descripción |
|---|---|---|---|
id | path string | Requerido | Webhook id. |
Cuerpo de la solicitud
{
"entityNumbers": [
"1033.022.383"
]
}Solicitud
curl -X POST https://companybelgium.be/api/v2/webhook/WEBHOOK_ID/subscriptions \
-H "X-API-Key: $API_BCE_KEY" \
-H "X-API-Secret: $API_BCE_SECRET" \
-H "Content-Type: application/json" \
-d '{"entityNumbers":["1033.022.383"]}'Respuesta
{
"success": true,
"data": {
"added": 1,
"entityNumbers": [
"1033022383"
]
},
"timestamp": "..."
}Remove entity subscriptions#
Unsubscribe the webhook from given entity numbers.
Parámetros
| Nombre | En/Tipo | Requerido | Descripción |
|---|---|---|---|
id | path string | Requerido | Webhook id. |
Cuerpo de la solicitud
{
"entityNumbers": [
"1033.022.383"
]
}Solicitud
curl -X DELETE https://companybelgium.be/api/v2/webhook/WEBHOOK_ID/subscriptions \
-H "X-API-Key: $API_BCE_KEY" \
-H "X-API-Secret: $API_BCE_SECRET" \
-H "Content-Type: application/json" \
-d '{"entityNumbers":["1033.022.383"]}'Respuesta
{
"success": true,
"data": {
"removed": 1
},
"timestamp": "..."
}Delivery log#
The most recent delivery attempts, newest first (100 by default, up to 500 with ?limit=), with response code, retries and error message.
Parámetros
| Nombre | En/Tipo | Requerido | Descripción |
|---|---|---|---|
id | path string | Requerido | Webhook id. |
Solicitud
curl https://companybelgium.be/api/v2/webhook/WEBHOOK_ID/events \
-H "X-API-Key: $API_BCE_KEY" \
-H "X-API-Secret: $API_BCE_SECRET"Respuesta
{
"success": true,
"data": [
{
"id": "...",
"url": "https://example.be/hooks/bce",
"entityNumbers": [
"1033022383"
],
"eventType": "manual",
"retryCount": 0,
"responseCode": 200,
"errorMessage": null,
"createdAt": "...",
"deliveredAt": "..."
}
],
"timestamp": "..."
}▶ Probar esta solicitud
Gestionar los webhooks de API BCE desde tu código#
La API de webhooks permite automatizar todo el ciclo de vida. Por ejemplo, cuando un cliente firma un contrato, tu CRM añade su número a las suscripciones del webhook. Cuando el contrato termina, lo retira. Así tu lista de empresas seguidas siempre refleja tu cartera real. Además, no necesitas un webhook por empresa: uno solo puede seguir varios números.
Para las entregas, el registro de eventos es tu primera herramienta de diagnóstico. Devuelve por defecto los 100 intentos más recientes, y hasta 500 con ?limit=. Cada entrada muestra el código de respuesta, los reintentos y el mensaje de error.
Buenas prácticas#
- Guarda el
hmacSecreten un gestor de secretos justo al crear el webhook. - Usa
POST /webhook/{id}/triggertras cada despliegue de tu receptor. - Pausa un webhook con
disabled: truedurante un mantenimiento en lugar de borrarlo. - Renueva el secreto con
PATCH /webhook/{id}/hmac-secrety despliega el nuevo enseguida. - Compara las suscripciones con tu base de datos de forma periódica.
Errores frecuentes#
El error más costoso es borrar un webhook por error. La eliminación arrastra sus suscripciones y su historial de entregas. Por eso, para una pausa, usa el indicador disabled. Otro error es renovar el secreto sin coordinar el despliegue. El secreto anterior deja de valer de inmediato, así que tu receptor rechazará los eventos hasta tener el nuevo. Ten en cuenta también que los webhooks forman parte del plan API Pro.
Ejemplo: sincronizar suscripciones con tu cartera
Supón que tu CRM contiene 500 clientes activos. Cada noche, un proceso lee las suscripciones del webhook con GET /webhook/{id}/subscriptions. Luego compara la lista con tu cartera. Por último, añade los números que faltan con un POST y retira los sobrantes con un DELETE en la misma ruta. Así la lista se corrige sola aunque un cambio manual se haya perdido. Además, puedes registrar cada diferencia encontrada para auditar el proceso. Ese registro te muestra también si algún equipo añade empresas fuera del CRM.
Preguntas frecuentes sobre API BCE y la API de webhooks#
¿Puedo seguir establecimientos además de empresas?
Sí. Las suscripciones aceptan números de empresa y también de establecimiento.
¿Cómo recupero el secreto HMAC si lo pierdo?
No es posible: solo se muestra una vez. Genera uno nuevo con el endpoint de renovación y luego actualiza tu receptor.
¿Puedo probar un webhook de API BCE sin esperar un cambio real?
Sí. El endpoint de entrega de prueba envía un evento manual para verificar tu endpoint y tu control de firma.