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

# Webhooks

> Recibe en tu servidor un aviso firmado cuando ocurre algo en el script.

## Eventos

| Evento | Cuándo |
| - | - |
| `repo.commit` | Se guardó un commit en el repositorio del script. |
| `functions.deploy` | Se publicó el backend (funciones y colecciones). |
| `access.granted` | Alguien recibió acceso al script. |
| `ping` | Prueba enviada desde el botón o la ruta de prueba. |

La dirección debe ser `https://` pública. Se rechazan las IP privadas y `localhost`. El secreto aparece **una sola vez**, al crear el webhook.

![Captura de pantalla: Token del Webhook DoglyTdc](https://mintcdn.com/dogly-tdc/qOnot79kPtISSKbW/images/scripts/scripts-webhook.png?fit=max\&auto=format\&n=qOnot79kPtISSKbW\&q=85\&s=acebfedc2e7ca71b6bfe1720dcba2661)

Token del Webhook DoglyTdc

## Qué llega

```http theme={null}
POST /seu-endereco
Content-Type: application/json
User-Agent: DoglyTdc-Scripts-Webhook/1
X-DoglyTdc-Event: repo.commit
X-DoglyTdc-Delivery: 1234
X-DoglyTdc-Timestamp: 1794015161
X-DoglyTdc-Signature: sha256=…

{ "id": "1234", "event": "repo.commit", "script_id": "…", "created_at": "…", "data": { … } }
```

## Verificar la firma

La firma es `sha256=` + el valor hexadecimal de HMAC-SHA256(secreto, `timestamp + "." + cuerpo sin procesar`). Rechaza las solicitudes con un timestamp de hace más de 5 minutos.

```js Node.js theme={null}
import crypto from "node:crypto";

export function valido(req, corpoCru, segredo) {
  const ts = req.headers["x-doglytdc-timestamp"];
  if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
  const esperado = "sha256=" + crypto.createHmac("sha256", segredo).update(`${ts}.${corpoCru}`).digest("hex");
  const recebido = req.headers["x-doglytdc-signature"] || "";
  return recebido.length === esperado.length && crypto.timingSafeEqual(Buffer.from(recebido), Buffer.from(esperado));
}
```

## Reintentos

* Hasta 3 intentos por aviso (de inmediato, después de 1 s y de 3 s).
* Las respuestas 4xx (excepto 429) no se reintentan.
* Después de 10 fallos consecutivos, el webhook se desactiva. Vuelve a activarlo desde el panel o mediante `PATCH`.

Rutas: [API › Webhooks](https://docs.doglytdc.dev/es/scripts/api-reference/webhooks.md).


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