
# Invia un evento di test a un endpoint webhook

`POST /v1/webhook-endpoints/{endpoint_id}:test` · autorizzazione `webhook-endpoints:write` · tutti i piani

Invia all'endpoint un evento sintetico firmato del tipo scelto (predefinito `user.created`) e restituisce l'esito. L'evento contiene `data.test = true` ed è firmato con il segreto attuale dell'endpoint, esattamente come una consegna reale, così puoi verificare la verifica della firma. Non viene scritta alcuna consegna e il corpo della risposta del destinatario non viene restituito. Ogni endpoint consente 10 test al minuto.

## Richiesta

| Campo | Tipo | Obbligatorio | Descrizione |
|---|---|---|---|
| `endpoint_id` | path | sì | ID dell'endpoint webhook (`whe_…`). |
| `event_type` | string | no | Tipo di evento del catalogo da inviare; predefinito `user.created`. Il corpo è facoltativo. |
| `Idempotency-Key` | header | no | Restituisce l'esito per una richiesta ripetuta con la stessa chiave. |

```json
{
  "event_type": "user.updated"
}
```

## Risposta

`200 OK` con l'esito. Una consegna fallita resta `200`: `succeeded` è `false` e `error_class` indica il motivo (`timeout`, `tls`, `dns`, `egress_blocked`, `http_status`, `connection`).

```json
{
  "succeeded": true,
  "http_status": 204,
  "error_class": null,
  "latency_ms": 87,
  "event_id": "evt_01k8a3m7s9v1w3x5y7z9b2c4d6"
}
```

## Errori

| HTTP | code | Quando |
|---|---|---|
| 400 | `unknown_field` | Il corpo contiene un campo non elencato sopra. |
| 404 | `not_found` | Nessun endpoint con questo ID in questo ambiente. |
| 409 | `conflict` | L'endpoint non è `enabled`. |
| 422 | `validation_failed` | `/event_type unknown_event_type`: non è un tipo del catalogo. |
| 429 | `rate_limited` | Più di 10 test al minuto per questo endpoint; riprova dopo `Retry-After`. |
| 401 | `unauthenticated` | La credenziale è mancante, non valida o revocata. |
| 403 | `insufficient_permissions` | La credenziale non ha `webhook-endpoints:write`. |
| 503 | `service_unavailable` | La gestione dei webhook è temporaneamente non disponibile; riprova dopo il periodo indicato in `Retry-After`. |

## Esempio

```bash
curl -X POST https://api.eu.keenauth.com/v1/webhook-endpoints/whe_01k8a3m5q7t9v1w3x5y7z9b2c4:test \
  -H "Authorization: Bearer $KEENAUTH_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"event_type":"user.updated"}'
```

CLI: `keenauth webhook-endpoints test whe_01k8a3m5q7t9v1w3x5y7z9b2c4 --event-type user.updated`
