Tutorial: Configurar webhooks
Recibe notificaciones en tiempo real cuando ocurren eventos en tu tienda.
1. Crea un endpoint receptor
Tu endpoint debe:
- Responder
200 OKen menos de 10 segundos - Ser HTTPS en producción
- Verificar la firma HMAC-SHA256
2. Registra el webhook via API
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",
"catalog.product.created"
],
"secret": "mi_secreto_hmac"
}'
3. Verifica la firma
// Go
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
)
func verifySignature(payload []byte, signature, secret string) bool {
mac := hmac.New(sha256.New, []byte(secret))
mac.Write(payload)
expected := hex.EncodeToString(mac.Sum(nil))
return hmac.Equal([]byte(expected), []byte(signature))
}
// TypeScript
import { createHmac } from "crypto";
function verifySignature(payload: string, signature: string, secret: string): boolean {
const expected = createHmac("sha256", secret).update(payload).digest("hex");
return expected === signature;
}
La firma viene en el header X-OmniBuy-Signature.
4. Maneja el evento
{
"id": "01J...",
"source": "/omnibuy/orders",
"type": "orders.order.created",
"time": "2026-04-08T12:00:00Z",
"tenantid": "<tenant-id>",
"data": {
"order_id": "...",
"total": 9800,
"currency": "PEN"
}
}
Ver el catálogo completo de eventos →.