# Webhooks


Puedes utilizar webhooks para provocar una acción en otro servicio en respuesta a un evento de envío (push) en el repositorio. Los webhooks son solicitudes POST que se envían a una URL que defines en Docker Hub.

## Crear un webhook

Para crear un webhook:
1. En el repositorio que elijas, selecciona la pestaña **Webhooks**.
2. Proporciona un nombre para el webhook.
3. Proporciona una URL de destino para el webhook. Aquí es donde se entregarán las solicitudes POST del webhook. La URL debe tener 255 caracteres o menos.
4. Selecciona **Create**.

## Ver el historial de entrega del webhook

Para ver el historial del webhook:
1. Pasa el cursor sobre tu webhook en la sección **Current Webhooks section**.
2. Selecciona el icono **Menu options**.
3. Selecciona **View History**.

A continuación, puedes ver el historial de entrega y si la entrega de la solicitud POST se realizó con éxito o no.

## Ejemplo de carga útil (payload) de un webhook

Las cargas útiles de los webhooks tienen el siguiente formato JSON:

```json
{
  "callback_url": "https://registry.hub.docker.com/u/svendowideit/testhook/hook/2141b5bi5i5b02bec211i4eeih0242eg11000a/",
  "push_data": {
    "pushed_at": 1417566161,
    "pusher": "trustedbuilder",
    "tag": "latest"
  },
  "repository": {
    "comment_count": 0,
    "date_created": 1417494799,
    "description": "",
    "dockerfile": "#\n# BUILD\u0009\u0009docker build -t svendowideit/apt-cacher .\n# RUN\u0009\u0009docker run -d -p 3142:3142 -name apt-cacher-run apt-cacher\n#\n# and then you can run containers with:\n# \u0009\u0009docker run -t -i -rm -e http_proxy http://192.168.1.2:3142/ debian bash\n#\nFROM\u0009\u0009ubuntu\n\n\nVOLUME\u0009\u0009[/var/cache/apt-cacher-ng]\nRUN\u0009\u0009apt-get update ; apt-get install -yq apt-cacher-ng\n\nEXPOSE \u0009\u00093142\nCMD\u0009\u0009chmod 777 /var/cache/apt-cacher-ng ; /etc/init.d/apt-cacher-ng start ; tail -f /var/log/apt-cacher-ng/*\n",
    "full_description": "Docker Hub based automated build from a GitHub repo",
    "is_official": false,
    "is_private": true,
    "is_trusted": true,
    "name": "testhook",
    "namespace": "svendowideit",
    "owner": "svendowideit",
    "repo_name": "svendowideit/testhook",
    "repo_url": "https://registry.hub.docker.com/u/svendowideit/testhook/",
    "star_count": 0,
    "status": "Active"
  }
}
```

> [!NOTE]
>
> El campo `callback_url` es un campo heredado (legacy) y ya no es compatible.
