# mv.missedCalls

> The missedCalls methods of @morevoice/sdk: Inbound calls nobody answered, as the callbacks inbox lists them.

Inbound calls nobody answered, as the callbacks inbox lists them. These methods are on `mv.missedCalls`, 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.

## `assign()`

**Assign a missed call.** As a supervisor: gives the item to a member to call back (they get a notice when the organization has them on), or back to the queue with `agent_id` null. Sends `missed_call.assigned`. Needs a live key, and a key that sees all the organization's calls.

```ts
mv.missedCalls.assign(id: MissedCallsAssignData["path"]["id"], body: MissedCallsAssignData["body"], options?: RequestOptions): Promise<MissedCallsAssignResponse>
```

`POST /missed_calls/{id}/assign` · [API reference](https://docs.morevoice.ai/api/operations/missed_calls_assign/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A call ID (`call_…`). |
| `body.agent_id` | `string \| null` | yes | `usr_…` ID. |
| `body.call_ids` | `string[]` | no | The item's calls as you listed them (`calls[].id`). Default: every call of the item now (a missed call that came in since you listed it is included). |
| `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

`MissedCall`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"missed_call"` | Always `missed_call`. |
| `id` | `string` | The item's ID: its newest call. Pass it to the missed-call actions. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `kind` | `"abandoned" \| "overflow" \| "voicemail" \| "unanswered" \| "failed"` | How the newest call was missed: `abandoned` (the caller left while waiting or ringing), `overflow` (a queue or route had nobody to take it), `voicemail` (they left a message), `unanswered` (it rang out) or `failed` (it failed before anyone answered). |
| `phone` | `string \| null` | The caller's number (E.164); null when it was withheld. |
| `dialled` | `string \| null` | The number they called (your line). |
| `started_at` | `string` | When the newest call started. |
| `first_at` | `string` | When the first call of the item started. |
| `count` | `integer` | Missed calls in the item. When missed calls are work items, every unhandled missed call of a number is one item; otherwise each call is its own item (1). |
| `calls` | `object[]` | The item's calls, newest first. |
| `waited_ms` | `integer \| null` | How long the caller waited (in the queue, else the call's length). |
| `queue_id` | `string \| null` | `q_…` ID. |
| `agent_id` | `string \| null` | `usr_…` ID. |
| `handled` | `object \| null` | How and when it was handled; null while it is open. |
| `attempts` | `object[]` | Calls back to the number that did not reach the caller (the last 10, oldest first). Listed when missed calls are work items; otherwise empty. |
| `attempts_total` | `integer` | All such attempts. |

### Example

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

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

const missedCall = await mv.missedCalls.assign("call_7Hk2Lm9Qp", {
	agent_id: "usr_4Gk2LmN9pQ4rS6tV8wX0yZ",
});
console.log(missedCall);
```

## `claim()`

**Take a missed call for an agent.** The agent pressing Call: the item becomes theirs so nobody else calls the same customer; 409 (`reason` missed_claimed) while someone else holds it. Only when missed calls are work items for the organization (409 `reason` not_work_items otherwise: assign it instead). Sends `missed_call.assigned`. The call must be one the agent's inbox shows. Needs a live key, and a key that sees all the organization's calls.

```ts
mv.missedCalls.claim(id: MissedCallsClaimData["path"]["id"], body: MissedCallsClaimData["body"], options?: RequestOptions): Promise<MissedCallsClaimResponse>
```

`POST /missed_calls/{id}/claim` · [API reference](https://docs.morevoice.ai/api/operations/missed_calls_claim/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A call ID (`call_…`). |
| `body.agent_id` | `string` | yes | The agent pressing Call: the item becomes theirs, unless someone else holds it (409). The call must be one they see. |
| `body.call_ids` | `string[]` | no | The item's calls as you listed them (`calls[].id`). Default: every call of the item now (a missed call that came in since you listed it is included). |
| `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

`MissedCall`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"missed_call"` | Always `missed_call`. |
| `id` | `string` | The item's ID: its newest call. Pass it to the missed-call actions. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `kind` | `"abandoned" \| "overflow" \| "voicemail" \| "unanswered" \| "failed"` | How the newest call was missed: `abandoned` (the caller left while waiting or ringing), `overflow` (a queue or route had nobody to take it), `voicemail` (they left a message), `unanswered` (it rang out) or `failed` (it failed before anyone answered). |
| `phone` | `string \| null` | The caller's number (E.164); null when it was withheld. |
| `dialled` | `string \| null` | The number they called (your line). |
| `started_at` | `string` | When the newest call started. |
| `first_at` | `string` | When the first call of the item started. |
| `count` | `integer` | Missed calls in the item. When missed calls are work items, every unhandled missed call of a number is one item; otherwise each call is its own item (1). |
| `calls` | `object[]` | The item's calls, newest first. |
| `waited_ms` | `integer \| null` | How long the caller waited (in the queue, else the call's length). |
| `queue_id` | `string \| null` | `q_…` ID. |
| `agent_id` | `string \| null` | `usr_…` ID. |
| `handled` | `object \| null` | How and when it was handled; null while it is open. |
| `attempts` | `object[]` | Calls back to the number that did not reach the caller (the last 10, oldest first). Listed when missed calls are work items; otherwise empty. |
| `attempts_total` | `integer` | All such attempts. |

### Example

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

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

const missedCall = await mv.missedCalls.claim("call_7Hk2Lm9Qp", {
	agent_id: "usr_4Gk2LmN9pQ4rS6tV8wX0yZ",
});
console.log(missedCall);
```

## `done()`

**Mark a missed call done.** Marks the item (every call of it) handled: it moves to the done view and sends `missed_call.done`. Acts for `agent_id` when given (the call must be one their inbox shows, as in the app), else for the organization. Needs a live key, and a key that sees all the organization's calls.

```ts
mv.missedCalls.done(id: MissedCallsDoneData["path"]["id"], body?: MissedCallsDoneData["body"], options?: RequestOptions): Promise<MissedCallsDoneResponse>
```

`POST /missed_calls/{id}/done` · [API reference](https://docs.morevoice.ai/api/operations/missed_calls_done/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A call ID (`call_…`). |
| `body.agent_id` | `string` | no | Mark it done as this agent (recorded as who handled it; the call must be one they see). Default: the organization (no agent). |
| `body.call_ids` | `string[]` | no | The item's calls as you listed them (`calls[].id`). Default: every call of the item now (a missed call that came in since you listed it is included). |
| `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

`MissedCall`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"missed_call"` | Always `missed_call`. |
| `id` | `string` | The item's ID: its newest call. Pass it to the missed-call actions. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `kind` | `"abandoned" \| "overflow" \| "voicemail" \| "unanswered" \| "failed"` | How the newest call was missed: `abandoned` (the caller left while waiting or ringing), `overflow` (a queue or route had nobody to take it), `voicemail` (they left a message), `unanswered` (it rang out) or `failed` (it failed before anyone answered). |
| `phone` | `string \| null` | The caller's number (E.164); null when it was withheld. |
| `dialled` | `string \| null` | The number they called (your line). |
| `started_at` | `string` | When the newest call started. |
| `first_at` | `string` | When the first call of the item started. |
| `count` | `integer` | Missed calls in the item. When missed calls are work items, every unhandled missed call of a number is one item; otherwise each call is its own item (1). |
| `calls` | `object[]` | The item's calls, newest first. |
| `waited_ms` | `integer \| null` | How long the caller waited (in the queue, else the call's length). |
| `queue_id` | `string \| null` | `q_…` ID. |
| `agent_id` | `string \| null` | `usr_…` ID. |
| `handled` | `object \| null` | How and when it was handled; null while it is open. |
| `attempts` | `object[]` | Calls back to the number that did not reach the caller (the last 10, oldest first). Listed when missed calls are work items; otherwise empty. |
| `attempts_total` | `integer` | All such attempts. |

### Example

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

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

const missedCall = await mv.missedCalls.done("call_7Hk2Lm9Qp", {
	agent_id: "usr_4Gk2LmN9pQ4rS6tV8wX0yZ",
});
console.log(missedCall);
```

## `list()`

**List missed calls.** Inbound calls nobody answered (the caller left, a queue or route had nobody, a voicemail, a call that rang out or failed), as the callbacks inbox lists them, newest first. When missed calls are work items for the organization, every unhandled missed call of one caller is one item (`count`, `calls`) with the call-back attempts that did not reach them. A missed call is handled when a later call reaches the caller, their callback is completed, or someone marks it done. With `agent_id`, as that agent's inbox shows them; without it, the whole organization. Needs a key that sees all the organization's calls.

```ts
mv.missedCalls.list(query?: NonNullable<MissedCallsListData["query"]>, options?: RequestOptions): PagedList<MissedCallsListResponse["data"][number], NonNullable<MissedCallsListData["query"]>>
```

`GET /missed_calls` · [API reference](https://docs.morevoice.ai/api/operations/missed_calls_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.view` | `string` | no | `open` (default): not handled yet. `mine`: open and held by `agent_id` (required). `queue`: open and nobody holds them. `done`: handled (marked done, a later call reached the caller, or their callback was completed). |
| `query.agent_id` | `string` | no | List as this agent sees the inbox: their queues' missed calls, the ones assigned to them and the calls their role shows. Default: the whole organization. |
| `query.kind` | `string` | no | Only this kind: `abandoned` (the caller left while waiting or ringing), `overflow` (a queue or route had nobody to take it), `voicemail` (they left a message), `unanswered` (it rang out) or `failed` (it failed before anyone answered). |
| `query.phone` | `string` | no | Only callers whose number contains these digits (3 or more). |
| `query.queue_id` | `string` | no | Only calls that waited in this queue. |
| `query.days` | `integer` | no | How many days back (1–30). Default: 30 for the open views when missed calls are work items, else 7. |
| `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 missedCall of mv.missedCalls.list()) {
	console.log(missedCall);
}
```

## `reopen()`

**Reopen a missed call.** Removes the done mark (sends `missed_call.reopened`). One that a later call reached stays handled. Acts for `agent_id` when given (the call must be one their inbox shows, as in the app), else for the organization. Needs a live key, and a key that sees all the organization's calls.

```ts
mv.missedCalls.reopen(id: MissedCallsReopenData["path"]["id"], body?: MissedCallsReopenData["body"], options?: RequestOptions): Promise<MissedCallsReopenResponse>
```

`POST /missed_calls/{id}/reopen` · [API reference](https://docs.morevoice.ai/api/operations/missed_calls_reopen/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | yes | A call ID (`call_…`). |
| `body.agent_id` | `string` | no | Reopen it as this agent (the call must be one they see). Default: the organization. |
| `body.call_ids` | `string[]` | no | The item's calls as you listed them (`calls[].id`). Default: every call of the item now (a missed call that came in since you listed it is included). |
| `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

`MissedCall`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"missed_call"` | Always `missed_call`. |
| `id` | `string` | The item's ID: its newest call. Pass it to the missed-call actions. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `kind` | `"abandoned" \| "overflow" \| "voicemail" \| "unanswered" \| "failed"` | How the newest call was missed: `abandoned` (the caller left while waiting or ringing), `overflow` (a queue or route had nobody to take it), `voicemail` (they left a message), `unanswered` (it rang out) or `failed` (it failed before anyone answered). |
| `phone` | `string \| null` | The caller's number (E.164); null when it was withheld. |
| `dialled` | `string \| null` | The number they called (your line). |
| `started_at` | `string` | When the newest call started. |
| `first_at` | `string` | When the first call of the item started. |
| `count` | `integer` | Missed calls in the item. When missed calls are work items, every unhandled missed call of a number is one item; otherwise each call is its own item (1). |
| `calls` | `object[]` | The item's calls, newest first. |
| `waited_ms` | `integer \| null` | How long the caller waited (in the queue, else the call's length). |
| `queue_id` | `string \| null` | `q_…` ID. |
| `agent_id` | `string \| null` | `usr_…` ID. |
| `handled` | `object \| null` | How and when it was handled; null while it is open. |
| `attempts` | `object[]` | Calls back to the number that did not reach the caller (the last 10, oldest first). Listed when missed calls are work items; otherwise empty. |
| `attempts_total` | `integer` | All such attempts. |

### Example

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

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

const missedCall = await mv.missedCalls.reopen("call_7Hk2Lm9Qp", {});
console.log(missedCall);
```
