> ## 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.

# Crear Webhook

> Crea un webhook para los eventos seleccionados.

#### Alcance

```bash theme={null}
write webhooks
```

## Qué hace

Crea un webhook para los eventos seleccionados. El `secret` de firma solo se devuelve en esta respuesta.

## Casos de uso

* Recibir ventas aprobadas en tu sistema
* Automatizar la entrega del producto

**url** `string` *required*

Dirección `https://` pública que recibe los eventos.

**events** `string[]` *required*

Uno o más de: `purchase_approved`, `pix_generated`, `purchase_refunded`, `subscription_created`, `subscription_renewed`, `subscription_canceled`, `withdrawal_paid`, `withdrawal_failed`, `affiliate_approved`.

**name** `string`

Nombre para identificarlo (hasta 80 caracteres). Por defecto: `API`.

## Respuesta

**data** `object`

**campos**

**id** `string\<uuid\>`

Identificador único.

**name** `string`

**url** `string`

**events** `string[]`

Eventos suscritos.

**active** `boolean`

Si recibe entregas.

**created\_at** `string\<date-time\>`

Cuándo fue creado.

**secret** `string`

Secreto de firma (`whsec_…`). Solo aparece aquí.

## Errores

| Estado | Descripción |
| - | - |
| `400` | `invalid_url` (debe ser https público) o `invalid_events`. |
| `401` | Clave inválida o revocada. |
| `403` | Faltan alcances (`insufficient_scope`). |
| `429` | Límite de solicitudes (`rate_limited`). |

```bash cURL theme={null}
curl --request POST \
  --url https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-pay/v1/webhooks \
  -u "$DPAY_CLIENT_ID:$DPAY_CLIENT_SECRET" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://mitienda.com/webhooks/doglytdc","events":["purchase_approved"]}'
```

```json 201 theme={null}
{
  "data": {
    "id": "c7d8e9f0-1a2b-4c3d-8e9f-0a1b2c3d4e5f",
    "name": "Mi tienda",
    "url": "https://mitienda.com/webhooks/doglytdc",
    "events": [
      "purchase_approved"
    ],
    "active": true,
    "created_at": "2026-11-06T18:10:00Z"
  },
  "secret": "whsec_8f3b…"
}
```

```json 401 theme={null}
{ "error": "unauthorized", "message": "Chave de API inválida." }
```

```json 403 theme={null}
{ "error": "insufficient_scope", "message": "Esta chave precisa dos escopos: write, webhooks." }
```


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