# mv.dnc

> The dnc methods of @morevoice/sdk: The organisation's do-not-call list and registry checks.

The organisation's do-not-call list and registry checks. These methods are on `mv.dnc`, 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.

## `check()`

**Check numbers before calling.** For each number: your do-not-call list, recorded consent and the national registry, combined into `callable` for the purpose. Read-only.

```ts
mv.dnc.check(body: DncCheckData["body"], options?: RequestOptions): Promise<DncCheckResponse>
```

`POST /dnc/check` · [API reference](https://docs.morevoice.ai/api/operations/dnc_check/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `body.phones` | `string[]` | yes | Up to 100 numbers. |
| `body.purpose` | `"service" \| "marketing" \| "survey"` | yes | The call's purpose. `marketing` requires recorded consent and a national-registry clearance (Israeli numbers); every purpose respects your do-not-call list. |
| `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

`DncCheck`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"dnc_check"` | Always `dnc_check`. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `purpose` | `"service" \| "marketing" \| "survey"` | — |
| `results` | `object[]` | — |

### Example

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

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

const dncCheck = await mv.dnc.check({
	phones: [
		"+972501234567",
		"0527654321",
	],
	purpose: "marketing",
});
console.log(dncCheck);
```

## `create()`

**Add numbers to the do-not-call list.** Adds up to 1,000 numbers. Each new number emits one `contact.opted_out` event, and queued campaign contacts with it are taken out at once. Needs a live key.

```ts
mv.dnc.create(body: DncCreateData["body"], options?: RequestOptions): Promise<DncCreateResponse>
```

`POST /dnc` · [API reference](https://docs.morevoice.ai/api/operations/dnc_create/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `body.phones` | `string[]` | yes | Up to 1000 numbers. |
| `body.reason` | `string` | no | A note kept with each entry. |
| `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

`DncBatch`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"dnc_batch"` | Always `dnc_batch`. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `added` | `string[]` | Numbers added now (E.164). Each emits one `contact.opted_out` event. |
| `already_listed` | `string[]` | Numbers that were on the list already (E.164). |
| `invalid` | `string[]` | Entries that are not valid phone numbers, as sent. |

### Example

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

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

const dncBatch = await mv.dnc.create({
	phones: [
		"+972501234567",
		"052-765-4321",
	],
	reason: "Opted out in the CRM",
});
console.log(dncBatch);
```

## `delete()`

**Remove a number from the do-not-call list.** Calls to the number are allowed again (marketing calls still need consent and the registry). Needs a live key.

```ts
mv.dnc.delete(phone: DncDeleteData["path"]["phone"], options?: RequestOptions): Promise<DncDeleteResponse>
```

`DELETE /dnc/{phone}` · [API reference](https://docs.morevoice.ai/api/operations/dnc_delete/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `phone` | `string` | yes | The number (URL-encode the `+` as `%2B`). |
| `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

`DeletedDncEntry`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"dnc_entry"` | Always `dnc_entry`. |
| `phone` | `string` | — |
| `deleted` | `true` | — |

### Example

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

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

const deletedDncEntry = await mv.dnc.delete("+972501234567");
console.log(deletedDncEntry);
```

## `list()`

**List the do-not-call list.** Lists the numbers on your do-not-call list, newest first: how each one got there and when. Filter by `phone` (any common format). Test keys can read the list; changing it needs a live key.

```ts
mv.dnc.list(query?: NonNullable<DncListData["query"]>, options?: RequestOptions): PagedList<DncListResponse["data"][number], NonNullable<DncListData["query"]>>
```

`GET /dnc` · [API reference](https://docs.morevoice.ai/api/operations/dnc_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.phone` | `string` | no | Only this number (any common form). |
| `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 dnc of mv.dnc.list()) {
	console.log(dnc);
}
```

## `retrieve()`

**Retrieve a do-not-call entry.** Returns the entry of one number on your do-not-call list: when it was added, how (`source`: the dashboard, an import, the API, or an opt-out during a call) and your note. `404` means the number is not on the list. To check a number against the national registry too, use `POST /v1/dnc/check`.

```ts
mv.dnc.retrieve(phone: DncRetrieveData["path"]["phone"], options?: RequestOptions): Promise<DncRetrieveResponse>
```

`GET /dnc/{phone}` · [API reference](https://docs.morevoice.ai/api/operations/dnc_retrieve/)

### Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `phone` | `string` | yes | The number (URL-encode the `+` as `%2B`). |
| `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

`DncEntry`:

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"dnc_entry"` | Always `dnc_entry`. |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |
| `phone` | `string` | The number, E.164. |
| `source` | `string` | How it was added: `manual`, `import`, `api`, `opt_out_tool` (asked the AI), `opt_out_phrase` or `opt_out_dtmf`. |
| `reason` | `string` | A free-text note. |
| `campaign_id` | `string \| null` | `cmp_…` ID. |
| `call_id` | `string \| null` | `call_…` ID. |
| `created` | `string` | An ISO-8601 timestamp in UTC. |

### Example

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

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

const dncEntry = await mv.dnc.retrieve("+972501234567");
console.log(dncEntry);
```
