Webhooks
Los webhooks permiten que WorkFlows notifique a tus sistemas en tiempo real cuando ocurren eventos. Configura endpoints HTTPS para recibir payloads firmados con HMAC-SHA256.
Crear un webhook
Crea webhooks desde Dashboard → Desarrolladores → Webhooks o via API. Selecciona los eventos que quieres recibir y proporciona un endpoint HTTPS.
curl -X POST https://www.workflows.com.es/api/v1/webhooks \
-H "Authorization: Bearer wf_live_abc123..." \
-H "Content-Type: application/json" \
-d '{
"name": "Slack Alerts",
"url": "https://my-server.com/webhooks/workflows",
"events": ["alert.created", "alert.critical", "alert.resolved"]
}'Formato del payload
Cada delivery envía un POST con los siguientes headers y body:
Content-Type: application/json
X-WorkFlows-Signature: sha256=<hex digest>
X-WorkFlows-Event: alert.created{
"event": "alert.created",
"orgId": "org_abc123",
"timestamp": "2026-05-19T16:30:00.000Z",
"data": {
"id": "alert_xyz789",
"title": "Inventario crítico: Materia Prima A",
"severity": "critical",
"status": "active",
"projectId": "proj_def456",
"area": "Inventario",
"createdAt": "2026-05-19T16:30:00.000Z"
}
}Verificar firmas
Cada payload incluye una firma HMAC-SHA256 en el header X-WorkFlows-Signature. Siempre verifica la firma antes de procesar el payload para asegurar que proviene de WorkFlows.
import crypto from "crypto";
function verifySignature(payload, signature, secret) {
const expected = "sha256=" +
crypto.createHmac("sha256", secret)
.update(payload)
.digest("hex");
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expected)
);
}
// En tu endpoint:
app.post("/webhooks/workflows", (req, res) => {
const signature = req.headers["x-workflows-signature"];
const isValid = verifySignature(
JSON.stringify(req.body),
signature,
process.env.WORKFLOWS_WEBHOOK_SECRET
);
if (!isValid) return res.status(401).send("Invalid signature");
// Procesar el evento...
const { event, data } = req.body;
console.log(`Evento recibido: ${event}`, data);
res.status(200).send("OK");
});import hmac
import hashlib
def verify_signature(payload: bytes, signature: str, secret: str) -> bool:
expected = "sha256=" + hmac.new(
secret.encode(),
payload,
hashlib.sha256
).hexdigest()
return hmac.compare_digest(signature, expected)
# En tu endpoint (Flask):
@app.route("/webhooks/workflows", methods=["POST"])
def handle_webhook():
signature = request.headers.get("X-WorkFlows-Signature", "")
if not verify_signature(request.data, signature, WEBHOOK_SECRET):
return "Invalid signature", 401
event = request.json["event"]
data = request.json["data"]
# Procesar...
return "OK", 200timingSafeEqual (Node.js) o hmac.compare_digest (Python) para evitar ataques de timing.Eventos disponibles
Suscríbete solo a los eventos que necesitas. Cada webhook puede escuchar múltiples eventos.
Alerts
| alert.created | Se creó una nueva alerta |
| alert.acknowledged | Una alerta fue reconocida |
| alert.assigned | Una alerta fue asignada a un usuario |
| alert.resolved | Una alerta fue resuelta |
| alert.critical | Se creó una alerta de severidad crítica |
| alert.deleted | Una alerta fue eliminada |
Projects
| project.created | Se creó un nuevo proyecto |
| project.updated | Un proyecto fue actualizado |
| project.deleted | Un proyecto fue eliminado |
Users
| user.invited | Un usuario fue invitado a la organización |
| user.joined | Un usuario aceptó la invitación |
| user.activated | Un usuario fue activado |
| user.deactivated | Un usuario fue desactivado |
Data
| csv.uploaded | Se subió un archivo CSV/Excel |
Connections
| db_connection.created | Se creó una conexión a base de datos |
| db_connection.updated | Una conexión fue actualizada |
| db_connection.deleted | Una conexión fue eliminada |
Queries
| query.completed | Una consulta de IA terminó |
| query.deleted | Un historial de consulta fue eliminado |
API Keys
| api_key.created | Se creó una nueva API key |
| api_key.deleted | Una API key fue eliminada |
Webhooks
| webhook.created | Se creó un nuevo webhook |
| webhook.enabled | Un webhook fue habilitado |
| webhook.disabled | Un webhook fue deshabilitado |
| webhook.deleted | Un webhook fue eliminado |
Reintentos
Si tu endpoint no responde con un status 2xx en 10 segundos, WorkFlows reintentará con backoff exponencial hasta 5 intentos:
| Intento | Espera | Tiempo acumulado |
|---|---|---|
| 1 | Inmediato | 0 min |
| 2 | 1 minuto | 1 min |
| 3 | 5 minutos | 6 min |
| 4 | 15 minutos | 21 min |
| 5 | 30 minutos | 51 min |
Después de 5 intentos fallidos, el delivery se marca como fallido. Puedes ver el historial de deliveries en Dashboard → Desarrolladores → Webhooks → Deliveries o via API con GET /api/v1/webhooks/{id}/deliveries.
Buenas prácticas
- Responde rápido — retorna
200lo antes posible y procesa el evento de forma asíncrona. - Verifica siempre la firma — no proceses payloads sin validar
X-WorkFlows-Signature. - Idempotencia — tu endpoint puede recibir el mismo evento más de una vez (reintentos). Usa el
data.idpara deduplicar. - Usa HTTPS — WorkFlows solo envía webhooks a endpoints HTTPS por seguridad.