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

# Criar Webhook

> Cria um webhook para os eventos escolhidos.

#### Escopo

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

## O que faz

Cria um webhook para os eventos escolhidos. O `secret` de assinatura volta só nesta resposta.

## Casos de uso

* Receber vendas aprovadas no seu sistema
* Automatizar a entrega do produto

**url** `string` *required*

Endereço `https://` público que recebe os eventos.

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

Um ou mais de: `purchase_approved`, `pix_generated`, `purchase_refunded`, `subscription_created`, `subscription_renewed`, `subscription_canceled`, `withdrawal_paid`, `withdrawal_failed`, `affiliate_approved`.

**name** `string`

Nome para você reconhecer (até 80 caracteres). Padrão: `API`.

## Resposta

**data** `object`

**campos**

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

Identificador único.

**name** `string`

**url** `string`

**events** `string[]`

Eventos inscritos.

**active** `boolean`

Se recebe entregas.

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

Quando foi criado.

**secret** `string`

Segredo de assinatura (`whsec_…`). Só aparece aqui.

## Erros

| Status | Descrição |
| - | - |
| `400` | `invalid_url` (precisa ser https público) ou `invalid_events`. |
| `401` | Chave inválida ou revogada. |
| `403` | Faltam escopos (`insufficient_scope`). |
| `429` | Limite de requisições (`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://minhaloja.com/webhooks/doglytdc","events":["purchase_approved"]}'
```

```json 201 theme={null}
{
  "data": {
    "id": "c7d8e9f0-1a2b-4c3d-8e9f-0a1b2c3d4e5f",
    "name": "Minha loja",
    "url": "https://minhaloja.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.