Saltar al contenido principal

Webhooks

Los webhooks te permiten recibir notificaciones en tiempo real cuando ocurren eventos en tu tienda, sin necesidad de hacer polling.

Formato de evento (CloudEvents v1.0)

{
"specversion": "1.0",
"id": "01J...",
"source": "/omnibuy/orders",
"type": "orders.order.created",
"time": "2026-04-08T12:00:00Z",
"datacontenttype": "application/json",
"tenantid": "<tenant-uuid>",
"data": { ... }
}

Registrar un webhook

curl -X POST https://app.omnibuy.net/api/v1/webhooks \
-H "Authorization: Bearer $TOKEN" \
-H "X-Tenant-ID: $TENANT" \
-H "Content-Type: application/json" \
-d '{
"url": "https://mi-app.com/webhooks/omnibuy",
"events": ["orders.order.created", "payments.payment.captured"],
"secret": "mi_secreto_hmac_256"
}'

Verificar la firma

Cada entrega incluye el header X-OmniBuy-Signature con un HMAC-SHA256 del body firmado con tu secret.

func verify(body []byte, sig, secret string) bool {
mac := hmac.New(sha256.New, []byte(secret))
mac.Write(body)
return hmac.Equal([]byte(hex.EncodeToString(mac.Sum(nil))), []byte(sig))
}

Endpoints de gestión

  • GET /api/v1/webhooks — listar
  • POST /api/v1/webhooks — crear
  • DELETE /api/v1/webhooks/:id — eliminar
  • GET /api/v1/webhooks/:id/deliveries — historial de entregas