# Preview a webhook against a call

Source: https://docs.usetone.ai/reference/integrations/previewWebhook

> Says what a delivery would do for one of your calls, with the `conditions` and `bodyTemplate` you send — saved or not: whether every condition holds, and the exact JSON it would POST.

`POST /v1/integrations/webhooks/preview`
Says what a delivery would do for one of your calls, with the `conditions` and `bodyTemplate` you send — saved or not: whether every condition holds, and the exact JSON it would POST. Without a `callId` it picks the newest ended call whose data meets the conditions, else the newest ended call. Nothing is sent and nothing is stored. A live key or the dashboard only: a test key gets `403`, because an endpoint receives live events too.

Requires the `admin` scope.

## Request body

| Field | Type | | Meaning |
|---|---|---|---|
| `agentIds` | string[] | null | optional | Pick the call from these agents' calls. |
| `bodyTemplate` | string | null | optional | The JSON to send instead of the standard envelope, with `{{path}}` placeholders — the same paths conditions use. A placeholder on its own keeps its type (`true`, a number, a list) and is `null` when the call has no value; inside quotes it is inserted as text, escaped, and empty when missing. At most 16 KB. Omit, or send null, for the standard envelope. |
| `callId` | string | optional | The call to fill it from. Omitted: the newest ended call — of `agentIds`, when given — whose data meets the conditions, else the newest ended call. |
| `conditions` | object[] | null | optional | Send only when ALL of these hold, checked once the call's data is filled. A delivery whose conditions do not hold is recorded `skipped` with the condition that failed, and nothing is sent. Omit, or send null, to send every event. |

### Example request

```json
{
  "bodyTemplate": "{\"order_id\": \"{{variables.order_number}}\", \"status\": \"cancelled\", \"reason\": {{outputs.cancellation_reason}}, \"tone_call_id\": \"{{call.id}}\"}",
  "callId": "b2e4c1d0-7a3f-4e1b-9c8d-2f6a5e4b3c21",
  "conditions": [
    {
      "field": "outputs.order_confirmed",
      "op": "eq",
      "value": "cancelled"
    }
  ]
}
```

## Response

| Field | Type | | Meaning |
|---|---|---|---|
| `body` | object | required | The JSON a delivery for that call would send: your template filled in, or the standard envelope. |
| `callId` | string | null | required | The call it was filled from. Null when there is no ended call yet; the body is then filled with nothing. |
| `matched` | boolean | required | Whether every condition holds for that call — whether a delivery would be sent. |
| `miss` | object | null | required | The first condition that did not hold. Null when all did. |

### Example response

```json
{
  "data": {
    "body": {
      "order_id": "#1042",
      "reason": "ordered_by_mistake",
      "status": "cancelled"
    },
    "callId": "9f1c2d84-4e3a-4f6c-b902-7d1e8a33c451",
    "matched": true,
    "miss": {
      "field": "outputs.order_confirmed",
      "index": 0,
      "reason": "no_value"
    }
  }
}
```
