# Check webhook deliveries

Send a webhook a test payload, read each delivery with the [run](/docs/concepts/runs.md) it started, and replay one to run it again.

## Before you start

You need a webhook that has received deliveries. See [Receive webhooks](/docs/orchestration/webhooks.md).

## Read and replay deliveries

**Studio**

1. In your project, open **Orchestration** > **Triggers**.

2. Open **Webhooks**.

3. Click the webhook, `Refund questions`.

4. Open its **Trigger** tab.

5. Enter this as the **Payload**:

   ```json
   {"type": "refund", "question": "How long does a refund take?"}
   ```

6. Click **Trigger webhook**. Studio opens **Events** with the new event **Queued** or **Running**.

7. Wait a few seconds. You should now see the event **Completed**.

8. If your webhook has a filter, click the arrow on an **Ignored** event. You should now see the reason, "Webhook event did not match configured filter", and its payload.

9. Open the **More actions** menu on a **Completed** event.

10. Click **Replay**. You should now see a new event at the top, **Queued** or **Running**, then **Completed**.

**API**

1. Set `PROJECT` to your project's ID ([Find your IDs](/docs/authentication/api-keys.md#find-your-ids)): `export PROJECT=<id>`.
2. List the project's webhooks, with your [API key](/docs/authentication/api-keys.md). You should now see each webhook's `id` and `name`:

```bash
curl https://api.veryfront.com/projects/$PROJECT/webhooks \
  -H "Authorization: Bearer $VERYFRONT_API_KEY"
```

3. Set `WEBHOOK_ID` to your webhook's `id`: `export WEBHOOK_ID=<id>`.
4. List the webhook's events, newest first. You should now see up to 50 events, each with its `status` and `run_id`. A filtered one is `ignored`, with its reason in `error_message`:

```bash
curl https://api.veryfront.com/projects/$PROJECT/webhooks/$WEBHOOK_ID/events \
  -H "Authorization: Bearer $VERYFRONT_API_KEY"
```

5. If `page_info.next` is not `null`, add `?cursor=` with that value. You should now see older events.
6. Set `EVENT_ID` to the `id` of the event to run again: `export EVENT_ID=<id>`.
7. Replay it. You should now see a new event, `queued` or `running`:

```bash
curl -X POST https://api.veryfront.com/projects/$PROJECT/webhooks/$WEBHOOK_ID/events/$EVENT_ID/replay \
  -H "Authorization: Bearer $VERYFRONT_API_KEY"
```

8. Repeat step 4 every few seconds. You should now see the new event at the top, `completed`, with its own `run_id`.

### Try it in a sandbox

```playground
step: Set PROJECT | export PROJECT=$VERYFRONT_PROJECT_ID
step: Before you start: an agent | curl -fsS -X POST https://api.veryfront.com/projects/$PROJECT/agents -H "Authorization: Bearer $VERYFRONT_API_KEY" -H "Content-Type: application/json" -d '{"id": "support", "name": "Support assistant", "system_prompt": "Answer customer questions about orders and refunds. Refunds take 5 business days. Keep replies to two sentences."}'
step: Before you start: the webhook, with a filter | curl -fsS -X POST https://api.veryfront.com/projects/$PROJECT/webhooks -H "Authorization: Bearer $VERYFRONT_API_KEY" -H "Content-Type: application/json" -d '{ "name": "Refund questions", "target": { "kind": "agent", "id": "support", "conversation_mode": "none" }, "prompt_template": "A customer asks: {{payload.question}}", "event_filter": { "mode": "all", "conditions": [{ "path": "type", "operator": "equals", "value": "refund" }] } }' | tee webhook.json
step: Set WEBHOOK_ID | export WEBHOOK_ID=$(jq -r .webhook.id webhook.json)
step: Before you start: its address and secret | export INGRESS_ID=$(jq -r .webhook.ingress_id webhook.json) WEBHOOK_SECRET=$(jq -r .webhook_secret webhook.json)
step: Before you start: a delivery that matches | curl -fsS -X POST https://api.veryfront.com/webhooks/$INGRESS_ID -H "X-Veryfront-Webhook-Secret: $WEBHOOK_SECRET" -H "Idempotency-Key: refund-question-1" -H "Content-Type: application/json" -d '{"type": "refund", "question": "How long does a refund take?"}'
step: Before you start: one the filter stops | curl -fsS -X POST https://api.veryfront.com/webhooks/$INGRESS_ID -H "X-Veryfront-Webhook-Secret: $WEBHOOK_SECRET" -H "Idempotency-Key: shipping-question-1" -H "Content-Type: application/json" -d '{"type": "shipping", "question": "Where is my parcel?"}'
step: Before you start: wait until one is completed and one ignored | for i in $(seq 40); do [ "$(curl -s https://api.veryfront.com/projects/$PROJECT/webhooks/$WEBHOOK_ID/events -H "Authorization: Bearer $VERYFRONT_API_KEY" | jq -r '[.data[].status] | sort | join(",")')" = "completed,ignored" ] && break; sleep 3; done
step: List the webhook's events | curl https://api.veryfront.com/projects/$PROJECT/webhooks/$WEBHOOK_ID/events -H "Authorization: Bearer $VERYFRONT_API_KEY" | tee events.json
step: Set EVENT_ID | export EVENT_ID=$(jq -r '[.data[] | select(.status == "completed")][0].id' events.json)
step: Replay it | curl -X POST https://api.veryfront.com/projects/$PROJECT/webhooks/$WEBHOOK_ID/events/$EVENT_ID/replay -H "Authorization: Bearer $VERYFRONT_API_KEY"
step: List the events until the new one is completed | for i in $(seq 40); do curl -s https://api.veryfront.com/projects/$PROJECT/webhooks/$WEBHOOK_ID/events -H "Authorization: Bearer $VERYFRONT_API_KEY" | jq -e '(.data | length) == 3 and .data[0].status == "completed"' > /dev/null && break; sleep 3; done
check: curl -s https://api.veryfront.com/projects/$PROJECT/webhooks/$WEBHOOK_ID/events -H "Authorization: Bearer $VERYFRONT_API_KEY" | jq -c '[.data[].status]'
expect: ["completed","ignored","completed"]
```

## With MCP

1. Call `veryfront__list_webhook_events` with `{ "project_reference": "my-project", "webhook_id": "<id>" }`. The project reference is its slug or its ID. If the webhook has a filter, a delivery it stopped has `"status": "ignored"`, no `run_id` and its reason in `error_message`.
2. While `page_info.next` is not `null`, call it again with that value as `cursor`: a call returns 50 events unless you set `limit` (up to 100).
3. Call `veryfront__replay_webhook_event` with the same `project_reference`, `webhook_id` and, as `webhook_event_id`, the `id` of an event that is `completed`.
4. Call `veryfront__list_webhook_events` again until the new event is `completed`: it starts `queued`, then `running`. It worked when the list holds one more event, with its own run.

## Next steps

* [Find a run that failed](/docs/observability/runs.md)
* [Debug a run](/docs/observability/debug.md)
