# mv.webhookDeliveries

> The webhookDeliveries methods of @morevoice/sdk: Delivery attempts of events to your endpoints.

Delivery attempts of events to your endpoints. These methods are on `mv.webhookDeliveries`, where `mv` is your client (see [the Node.js SDK](https://docs.morevoice.ai/sdk/node/#connect)). Each one returns the response object and throws when the API answers with an error.

## `list()`

**List webhook deliveries.** Deliveries of events to your endpoints in this mode, newest first. Filter by endpoint, event or status (`status=failed` for the ones being retried). Kept 30 days.

```ts
mv.webhookDeliveries.list(query?: NonNullable<WebhookDeliveriesListData["query"]>, options?: RequestOptions): PagedList<WebhookDeliveriesListResponse["data"][number], NonNullable<WebhookDeliveriesListData["query"]>>
```

`GET /webhook_deliveries` · [API reference](https://docs.morevoice.ai/api/operations/webhook_deliveries_list/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `query.limit` | `integer` | no | How many objects to return, 1–100 (default 20). |
| `query.starting_after` | `string` | no | A cursor (`next_cursor`) or object ID: return the objects after it (older). |
| `query.ending_before` | `string` | no | A cursor or object ID: return the objects before it (newer). |
| `query.endpoint_id` | `string` | no | A webhook endpoint ID (`we_…`). |
| `query.event_id` | `string` | no | A event ID (`evt_…`). |
| `query.status` | `string` | no |  |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

A [`PagedList`](https://docs.morevoice.ai/sdk/typescript/pagination/): `await` it for the first page, `for await` it for every item.

### Example

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

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

for await (const webhookDelivery of mv.webhookDeliveries.list()) {
	console.log(webhookDelivery);
}
```

## `retrieve()`

**Retrieve a webhook delivery.** The delivery with the request as last sent (headers without the signatures, the exact body) and the start of the endpoint's answer.

```ts
mv.webhookDeliveries.retrieve(id: WebhookDeliveriesRetrieveData["path"]["id"], options?: RequestOptions): Promise<WebhookDeliveriesRetrieveResponse>
```

`GET /webhook_deliveries/{id}` · [API reference](https://docs.morevoice.ai/api/operations/webhook_deliveries_retrieve/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A webhook delivery ID (`whd_…`). |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

`WebhookDelivery`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | A webhook delivery ID (prefix `whd_`). |
| `object` | `"webhook_delivery"` | Always `webhook_delivery`. |
| `endpoint_id` | `string` | A webhook endpoint ID (prefix `we_`). |
| `event_id` | `string` | A event ID (prefix `evt_`). |
| `event_type` | `string \| null` | — |
| `status` | `"pending" \| "failed" \| "succeeded" \| "dead"` | `pending`: not sent yet. `failed`: the last attempt failed; retried at `next_attempt_at` (for up to 72 hours). `succeeded`: answered 2xx. `dead`: given up. |
| `attempts` | `integer` | — |
| `next_attempt_at` | `string \| null` | — |
| `last_attempt_at` | `string \| null` | — |
| `delivered_at` | `string \| null` | — |
| `response_status` | `integer \| null` | — |
| `response_excerpt` | `string \| null` | The first 2 KB of the endpoint's last answer. |
| `duration_ms` | `integer \| null` | How long the last attempt took. |
| `error` | `string \| null` | — |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |
| `request` | `object` | The request as last sent (retrieve only). |

### Example

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

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

const webhookDelivery = await mv.webhookDeliveries.retrieve("whd_7Hk2Lm9Qp");
console.log(webhookDelivery);
```

## `retry()`

**Retry a webhook delivery.** Sends the delivery again right now (a dead one too) and returns it with the outcome. A retry that fails leaves a dead delivery dead; a delivery still being retried keeps its schedule.

```ts
mv.webhookDeliveries.retry(id: WebhookDeliveriesRetryData["path"]["id"], options?: RequestOptions): Promise<WebhookDeliveriesRetryResponse>
```

`POST /webhook_deliveries/{id}/retry` · [API reference](https://docs.morevoice.ai/api/operations/webhook_deliveries_retry/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A webhook delivery ID (`whd_…`). |
| `options.headers["MoreVoice-Version"]` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `options.headers["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. |
| `options` | `RequestOptions` | no | `idempotencyKey`, extra `headers` and an abort `signal`: see [retries and idempotency](https://docs.morevoice.ai/sdk/typescript/retries/). |

### Returns

`WebhookDelivery`:

| Field | Type | Description |
| --- | --- | --- |
| `id` | `string` | A webhook delivery ID (prefix `whd_`). |
| `object` | `"webhook_delivery"` | Always `webhook_delivery`. |
| `endpoint_id` | `string` | A webhook endpoint ID (prefix `we_`). |
| `event_id` | `string` | A event ID (prefix `evt_`). |
| `event_type` | `string \| null` | — |
| `status` | `"pending" \| "failed" \| "succeeded" \| "dead"` | `pending`: not sent yet. `failed`: the last attempt failed; retried at `next_attempt_at` (for up to 72 hours). `succeeded`: answered 2xx. `dead`: given up. |
| `attempts` | `integer` | — |
| `next_attempt_at` | `string \| null` | — |
| `last_attempt_at` | `string \| null` | — |
| `delivered_at` | `string \| null` | — |
| `response_status` | `integer \| null` | — |
| `response_excerpt` | `string \| null` | The first 2 KB of the endpoint's last answer. |
| `duration_ms` | `integer \| null` | How long the last attempt took. |
| `error` | `string \| null` | — |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |
| `request` | `object` | The request as last sent (retrieve only). |

### Example

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

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

const webhookDelivery = await mv.webhookDeliveries.retry("whd_7Hk2Lm9Qp");
console.log(webhookDelivery);
```
