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

> Rotas da API do Scripts: webhooks.

| Método | Caminho | O que faz |
| - | - | - |
| `GET` | `/scripts/{script_id}/webhooks` | Webhooks de eventos do script. |
| `POST` | `/scripts/{script_id}/webhooks` | Cria um webhook (máx. 5). A chave de assinatura (whsec\_…) aparece só nesta resposta. Assinatura: X-DoglyTdc-Signature = sha256=HMAC\_SHA256(chave, "X-DoglyTdc-Timestamp.corpo"). |
| `PATCH` | `/scripts/{script_id}/webhooks/{webhook_id}` | Muda URL, eventos ou ativa/desativa. |
| `DELETE` | `/scripts/{script_id}/webhooks/{webhook_id}` | Apaga o webhook. |
| `POST` | `/scripts/{script_id}/webhooks/{webhook_id}/test` | Envia um evento "ping" agora. |
| `GET` | `/scripts/{script_id}/webhooks/{webhook_id}/deliveries` | Últimas 50 entregas. |

## GET /scripts/\{script\_id}/webhooks

Webhooks de eventos do script.

**Autenticação:** Escopo: `scripts.read`

**Parâmetros do caminho:** `script_id`

**Resposta:** `Webhook[]`

```bash cURL theme={null}
curl -X GET "https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-scripts-api/scripts/{script_id}/webhooks" \
  -H "Authorization: Bearer dts_SEU_TOKEN"
```

## POST /scripts/\{script\_id}/webhooks

Cria um webhook (máx. 5). A chave de assinatura (whsec\_…) aparece só nesta resposta. Assinatura: X-DoglyTdc-Signature = sha256=HMAC\_SHA256(chave, "X-DoglyTdc-Timestamp.corpo").

**Autenticação:** Escopo: `scripts.write`

> [!NOTE]
>
> Até 5 webhooks por script. A chave de assinatura `whsec_…` aparece **só nesta resposta**.

**Parâmetros do caminho:** `script_id`

**Corpo:** `{ url (https público), events?: (repo.commit | functions.deploy | access.granted)[] }`

**Resposta:** `{ webhook, secret }`

```bash cURL theme={null}
curl -X POST "https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-scripts-api/scripts/{script_id}/webhooks" \
  -H "Authorization: Bearer dts_SEU_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"url":"https://exemplo.com/hook","events":["repo.commit"]}'
```

## PATCH /scripts/\{script\_id}/webhooks/\{webhook\_id}

Muda URL, eventos ou ativa/desativa.

**Autenticação:** Escopo: `scripts.write`

**Parâmetros do caminho:** `script_id`, `webhook_id`

**Corpo:** `{ url?, events?, active? }`

**Resposta:** `Webhook`

```bash cURL theme={null}
curl -X PATCH "https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-scripts-api/scripts/{script_id}/webhooks/{webhook_id}" \
  -H "Authorization: Bearer dts_SEU_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"active":false}'
```

## DELETE /scripts/\{script\_id}/webhooks/\{webhook\_id}

Apaga o webhook.

**Autenticação:** Escopo: `scripts.write`

**Parâmetros do caminho:** `script_id`, `webhook_id`

**Resposta:** `204`

```bash cURL theme={null}
curl -X DELETE "https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-scripts-api/scripts/{script_id}/webhooks/{webhook_id}" \
  -H "Authorization: Bearer dts_SEU_TOKEN"
```

## POST /scripts/\{script\_id}/webhooks/\{webhook\_id}/test

Envia um evento "ping" agora.

**Autenticação:** Escopo: `scripts.write`

**Parâmetros do caminho:** `script_id`, `webhook_id`

**Resposta:** `Delivery`

```bash cURL theme={null}
curl -X POST "https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-scripts-api/scripts/{script_id}/webhooks/{webhook_id}/test" \
  -H "Authorization: Bearer dts_SEU_TOKEN"
```

## GET /scripts/\{script\_id}/webhooks/\{webhook\_id}/deliveries

Últimas 50 entregas.

**Autenticação:** Escopo: `scripts.read`

**Parâmetros do caminho:** `script_id`, `webhook_id`

**Resposta:** `Delivery[]`

```bash cURL theme={null}
curl -X GET "https://ucsyxzpdbnuyehizezvb.supabase.co/functions/v1/doglytdc-scripts-api/scripts/{script_id}/webhooks/{webhook_id}/deliveries" \
  -H "Authorization: Bearer dts_SEU_TOKEN"
```


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