Webhooks
Endpoints, el libro de eventos, inspección de entregas y reintento manual.
Base: https://api.facturia.cl/v1. Todos los endpoints de este capítulo se autentican con Authorization: Bearer salvo que se diga lo contrario, y el sobre de error es el de Errores.
| Método | Ruta | Qué hace |
|---|---|---|
GET | /webhook_endpoints | Lista los endpoints de webhook |
POST | /webhook_endpoints | Registra un endpoint de webhook |
GET | /webhook_endpoints/{webhook_endpoint_id} | Devuelve un endpoint de webhook |
PATCH | /webhook_endpoints/{webhook_endpoint_id} | Actualiza un endpoint de webhook |
DELETE | /webhook_endpoints/{webhook_endpoint_id} | Elimina un endpoint de webhook |
POST | /webhook_endpoints/{webhook_endpoint_id}/ping | Envía un evento sintético para verificar la conexión |
POST | /webhook_endpoints/{webhook_endpoint_id}/rotate_secret | Rota el secreto de firma |
GET | /webhook_endpoints/{webhook_endpoint_id}/deliveries | Inspecciona los intentos de entrega |
POST | /webhook_endpoints/{webhook_endpoint_id}/deliveries/{delivery_id}/retry | Reenvía un evento |
GET | /events | Consulta el libro de eventos (retención de 12 meses) |
GET | /events/{event_id} | Devuelve un evento |
GET /webhook_endpoints
Lista los endpoints de webhook
curl -sS https://api.facturia.cl/v1/webhook_endpoints \
-H "Authorization: Bearer $FACTURIA_KEY"Parámetros
| Parámetro | En | Requerido | Tipo | Notas |
|---|---|---|---|---|
limit | query | — | integer | |
cursor | query | — | string | Cursor opaco tomado del next_cursor de una respuesta anterior. |
Respuestas
| Código | Significado | Cuerpo |
|---|---|---|
200 | Una lista de endpoints. | lista de WebhookEndpoint |
POST /webhook_endpoints
Registra un endpoint de webhook
El secret se devuelve una sola vez, al crearlo, y nunca más.
curl -sS -X POST https://api.facturia.cl/v1/webhook_endpoints \
-H "Authorization: Bearer $FACTURIA_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"url":"https://api.miempresa.cl/hooks/facturia"}'Parámetros
| Parámetro | En | Requerido | Tipo | Notas |
|---|---|---|---|---|
Idempotency-Key | header | — | string | Llave que genera el cliente, única por operación lógica, retenida 24 h y con alcance (cuenta, empresa, endpoint). Un replay devuelve la respuesta original con Facturia-Idempotent-Replay: true. Misma llave y cuerpo distinto → 409. |
Cuerpo
| Campo | Tipo | Requerido | Notas |
|---|---|---|---|
url | string | sí | |
description | string | — | |
enabled_events | string[] | — | Tipos de evento, o ["*"] para todo, incluidos los tipos futuros. Por defecto: ["*"]. |
empresas | Rut[] | — | Restringe las entregas a estas empresas. Por defecto, todas las que la llave puede ver. |
| Respuestas |
| Código | Significado | Cuerpo |
|---|---|---|
201 | El endpoint creado, con su secreto de firma. | WebhookEndpointWithSecret |
GET /webhook_endpoints/{webhook_endpoint_id}
Devuelve un endpoint de webhook
curl -sS https://api.facturia.cl/v1/webhook_endpoints/whe_01K2RF5N8Q2W \
-H "Authorization: Bearer $FACTURIA_KEY"Parámetros
| Parámetro | En | Requerido | Tipo | Notas |
|---|---|---|---|---|
webhook_endpoint_id | path | sí | string |
Respuestas
| Código | Significado | Cuerpo |
|---|---|---|
200 | El endpoint. | WebhookEndpoint |
PATCH /webhook_endpoints/{webhook_endpoint_id}
Actualiza un endpoint de webhook
curl -sS -X PATCH https://api.facturia.cl/v1/webhook_endpoints/whe_01K2RF5N8Q2W \
-H "Authorization: Bearer $FACTURIA_KEY" \
-H "Content-Type: application/json" \
-d '{"url":"https://api.miempresa.cl/hooks/facturia","description":"…"}'Parámetros
| Parámetro | En | Requerido | Tipo | Notas |
|---|---|---|---|---|
webhook_endpoint_id | path | sí | string |
Cuerpo
| Campo | Tipo | Requerido | Notas |
|---|---|---|---|
url | string | — | |
description | string | — | |
enabled_events | string[] | — | |
empresas | Rut[] | — | |
status | enabled · disabled | — | |
| Respuestas |
| Código | Significado | Cuerpo |
|---|---|---|
200 | El endpoint actualizado. | WebhookEndpoint |
DELETE /webhook_endpoints/{webhook_endpoint_id}
Elimina un endpoint de webhook
curl -sS -X DELETE https://api.facturia.cl/v1/webhook_endpoints/whe_01K2RF5N8Q2W \
-H "Authorization: Bearer $FACTURIA_KEY"Parámetros
| Parámetro | En | Requerido | Tipo | Notas |
|---|---|---|---|---|
webhook_endpoint_id | path | sí | string |
Respuestas
| Código | Significado | Cuerpo |
|---|---|---|
204 | Eliminado. | — |
POST /webhook_endpoints/{webhook_endpoint_id}/ping
Envía un evento sintético para verificar la conexión
curl -sS -X POST https://api.facturia.cl/v1/webhook_endpoints/whe_01K2RF5N8Q2W/ping \
-H "Authorization: Bearer $FACTURIA_KEY"Parámetros
| Parámetro | En | Requerido | Tipo | Notas |
|---|---|---|---|---|
webhook_endpoint_id | path | sí | string |
Respuestas
| Código | Significado | Cuerpo |
|---|---|---|
202 | El intento de entrega. | WebhookDelivery |
POST /webhook_endpoints/{webhook_endpoint_id}/rotate_secret
Rota el secreto de firma
El secreto anterior sigue firmando 24 horas, así que puedes desplegar sin corte.
curl -sS -X POST https://api.facturia.cl/v1/webhook_endpoints/whe_01K2RF5N8Q2W/rotate_secret \
-H "Authorization: Bearer $FACTURIA_KEY"Parámetros
| Parámetro | En | Requerido | Tipo | Notas |
|---|---|---|---|---|
webhook_endpoint_id | path | sí | string |
Respuestas
| Código | Significado | Cuerpo |
|---|---|---|
200 | El endpoint con su secreto nuevo. | WebhookEndpointWithSecret |
GET /webhook_endpoints/{webhook_endpoint_id}/deliveries
Inspecciona los intentos de entrega
curl -sS https://api.facturia.cl/v1/webhook_endpoints/whe_01K2RF5N8Q2W/deliveries \
-H "Authorization: Bearer $FACTURIA_KEY"Parámetros
| Parámetro | En | Requerido | Tipo | Notas |
|---|---|---|---|---|
webhook_endpoint_id | path | sí | string | |
limit | query | — | integer | |
cursor | query | — | string | Cursor opaco tomado del next_cursor de una respuesta anterior. |
status | query | — | pending · succeeded · failed | |
event_id | query | — | string |
Respuestas
| Código | Significado | Cuerpo |
|---|---|---|
200 | Una lista de entregas. | lista de WebhookDelivery |
POST /webhook_endpoints/{webhook_endpoint_id}/deliveries/{delivery_id}/retry
Reenvía un evento
curl -sS -X POST https://api.facturia.cl/v1/webhook_endpoints/whe_01K2RF5N8Q2W/deliveries/whd_01K2RG1P4M7X01/retry \
-H "Authorization: Bearer $FACTURIA_KEY"Parámetros
| Parámetro | En | Requerido | Tipo | Notas |
|---|---|---|---|---|
webhook_endpoint_id | path | sí | string | |
delivery_id | path | sí | string |
Respuestas
| Código | Significado | Cuerpo |
|---|---|---|
202 | El nuevo intento de entrega. | WebhookDelivery |
GET /events
Consulta el libro de eventos (retención de 12 meses)
La retención es de 12 meses — a propósito más larga que un libro de webhooks típico, para que
un ciclo tributario completo de F29 siga siendo reproducible. La entrega es al-menos-una-vez y sin
orden garantizado; deduplica por id.
curl -sS https://api.facturia.cl/v1/events \
-H "Authorization: Bearer $FACTURIA_KEY"Parámetros
| Parámetro | En | Requerido | Tipo | Notas |
|---|---|---|---|---|
limit | query | — | integer | |
cursor | query | — | string | Cursor opaco tomado del next_cursor de una respuesta anterior. |
type | query | — | string | |
empresa_rut | query | — | Rut | |
created_at[gte] | query | — | string |
Respuestas
| Código | Significado | Cuerpo |
|---|---|---|
200 | Una lista de eventos. | lista de Event |
GET /events/{event_id}
Devuelve un evento
curl -sS https://api.facturia.cl/v1/events/evt_01K2RG1P4M7X \
-H "Authorization: Bearer $FACTURIA_KEY"Parámetros
| Parámetro | En | Requerido | Tipo | Notas |
|---|---|---|---|---|
event_id | path | sí | string |
Respuestas
| Código | Significado | Cuerpo |
|---|---|---|
200 | El evento. | Event |