# Send a test event

`POST https://api.morevoice.ai/v1/webhook_endpoints/{id}/test`

Sends one sample event of `type` to the endpoint now, signed like a real delivery, and reports how it answered. Samples are not stored and never retried.

Authenticate with a secret API key: `Authorization: Bearer $MOREVOICE_API_KEY`.

Operation ID: `webhook_endpoints_test`.

## Parameters

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A webhook endpoint ID (`we_…`). |

### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `MoreVoice-Version` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `Idempotency-Key` | `string` | no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |

## Request body

Optional, `application/json`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | `"call.created" \| "call.started" \| "call.ringing" \| "call.answered" \| "call.transferred" \| "call.ended" \| "call.analyzed" \| "call.cost_finalized" \| …` | no | The event type to send a sample of (default `test`). |

Example:

```json
{
  "type": "call.ended"
}
```

## Responses

### 200 OK

OK Returns `WebhookEndpointTest`.

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"webhook_endpoint_test"` | — |
| `endpoint_id` | `string` | A webhook endpoint ID (prefix `we_`). |
| `event_id` | `string` | The sample's id (the `webhook-id` header). Samples are not stored. |
| `type` | `"call.created" \| "call.started" \| "call.ringing" \| "call.answered" \| "call.transferred" \| "call.ended" \| "call.analyzed" \| "call.cost_finalized" \| …` | — |
| `delivered` | `boolean` | The endpoint answered 2xx. |
| `response_status` | `integer \| null` | The HTTP status it answered (null: no answer, e.g. a timeout or a refused address). |
| `duration_ms` | `integer \| null` | — |
| `error` | `string \| null` | — |
| `response_excerpt` | `string \| null` | The first 2 KB of its answer. |

Example:

```json
{
  "delivered": true,
  "duration_ms": 182,
  "endpoint_id": "we_4Gk2LmN9pQ4rS6tV8wX0yZ",
  "error": null,
  "event_id": "evt_3fT9kq2ZpLr8YwVbN1cX0a",
  "object": "webhook_endpoint_test",
  "response_excerpt": "ok",
  "response_status": 200,
  "type": "call.ended"
}
```

### 400 Bad Request

The request is invalid: a parameter is missing, malformed or unknown, or the version header is unknown. Returns `ErrorEnvelope`.

### 401 Unauthorized

No valid API key was sent. Returns `ErrorEnvelope`.

### 403 Forbidden

The key may not do this (a missing scope, a plan limit, or a compliance block). Returns `ErrorEnvelope`.

### 404 Not Found

No object with this ID (in the path or the body) exists in this organisation and mode. Returns `ErrorEnvelope`.

### 409 Conflict

The request conflicts with the object's state, or the Idempotency-Key was reused with other parameters. Returns `ErrorEnvelope`.

### 413 Payload Too Large

The request body is larger than the endpoint accepts, or has more parts or files than it takes. Returns `ErrorEnvelope`.

### 415 Unsupported Media Type

The request body's Content-Type is not one the endpoint takes. Returns `ErrorEnvelope`.

### 429 Too Many Requests

Too many requests, or no call capacity right now. Retry after the Retry-After delay. Returns `ErrorEnvelope`.

### 500 Internal Server Error

Something went wrong on MoreVoice's side. Retry with the same Idempotency-Key. Returns `ErrorEnvelope`.

## Code samples

**TypeScript**

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const webhookEndpointTest = await mv.webhookEndpoints.test("we_7Hk2Lm9Qp", {
	type: "call.ended",
});
console.log(webhookEndpointTest);
```

**Python**

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

webhook_endpoint_test = client.webhook_endpoints.test("we_7Hk2Lm9Qp", {
    "type": "call.ended",
})
print(webhook_endpoint_test)
```

**cURL**

```sh
curl -X POST https://api.morevoice.ai/v1/webhook_endpoints/we_7Hk2Lm9Qp/test \
  -H "Authorization: Bearer $MOREVOICE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "type": "call.ended"
}'
```
