> ## Documentation Index
> Fetch the complete documentation index at: https://docs.interactivelayers.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhooks y eventos

> Recibí lotes firmados y conciliá eventos mediante un cursor.

## Registrá y probá un endpoint HTTPS

Registrá el endpoint para la clave dueña de los eventos. Guardá el `webhook_secret` devuelto al registrar la URL y evitá que la respuesta quede en logs compartidos. La entrega empieza con los eventos nuevos posteriores al registro. La prueba envía un evento firmado `webhook.test`. Comprobá `delivered` y el registro del receptor una vez que tu verificador tenga el secreto.

```bash theme={null}
curl -fsS -X PUT "$INTERACTIVE_LAYERS_BASE/v1/keys/me/webhook" \
  -H "X-API-Key: $INTERACTIVE_LAYERS_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"url":"https://receiver.example/interactivelayers/events"}'

curl -fsS -X POST "$INTERACTIVE_LAYERS_BASE/v1/keys/me/webhook/test" \
  -H "X-API-Key: $INTERACTIVE_LAYERS_API_KEY"
```

## Verificá los bytes originales del cuerpo

Usá `X-InteractiveLayers-Key-Id` para elegir el secreto configurado. Leé `X-InteractiveLayers-Timestamp` y `X-InteractiveLayers-Signature`. La firma es el HMAC-SHA256 hexadecimal del timestamp, un punto y los bytes exactos del cuerpo HTTP. Validala antes de decodificar el JSON. Durante la transición, los headers anteriores `X-Clipma-*` pueden acompañar a los actuales.

```python theme={null}
import hashlib
import hmac
import re
import time


def verify(secret: str, timestamp: str, raw_body: bytes, signature: str) -> bool:
    if not re.fullmatch(r"[0-9]{1,12}", timestamp):
        return False
    if not re.fullmatch(r"[0-9a-f]{64}", signature):
        return False
    if abs(time.time() - int(timestamp)) > 300:
        return False
    signed_bytes = timestamp.encode("ascii") + b"." + raw_body
    expected = hmac.new(secret.encode("utf-8"), signed_bytes, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected, signature)
```

El cuerpo tiene la forma `{"events":[...]}`. Confirmá el lote después de persistirlo y deduplicá por `id` de evento. Un lote que falla tres veces se da por omitido. Para conciliar, consultá `GET /v1/events?since=0&types=break.signal,source.error` con `events:read`. Guardá `next_since` aun si la página está vacía y usalo para la próxima consulta con los mismos filtros. `seq` indica la posición del cursor. Entre los tipos están `opportunity.detected`, `brand_safety.hold`, `break.announced`, `break.signal`, `break.decided` y `vod.scan.completed`. El evento de prueba tiene `seq: 0` y permite comprobar el receptor. [Errores y reintentos](https://docs.interactivelayers.com/es/errors.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.