# Do-Not-Call API

Source: https://aicallstudio.com/docs/api/dnc. Authentication, scopes, limits, errors and webhooks: https://aicallstudio.com/docs/api

### Add a number to Do-Not-Call

`POST /api/v1/dnc` (scope `dnc:write`)

Put a number on your Do-Not-Call list. It is never called again, by any campaign, workflow or person, until it is taken off. Every contact with the number is marked.

**Parameters**

| Parameter | Type | What it is |
| --- | --- | --- |
| `Idempotency-Key` | string, up to 255 characters, in the headers | Any unique text up to 255 characters, such as a UUID, chosen by you for this request. Sent again with the same body within 24 hours, the first answer comes back (with Idempotent-Replayed: true) and nothing is done twice. The same key with another body is refused with 422. |

**Request body (application/json)**

| Field | Type | What it is |
| --- | --- | --- |
| `phone` (required) | string, up to 20 characters | The number never to call, in any format. |

**Answer (200): these fields**

| Field | Type | What it is |
| --- | --- | --- |
| `phone` (required) | string | — |
| `on_list` (required) | boolean | Whether the number is on the Do-Not-Call list now. |
| `changed` (required) | boolean | false when it already was (adding) or already was not (removing). |

**Errors**

| Code | When |
| --- | --- |
| `401` | The token is missing, unknown or revoked, or its workspace was deleted. |
| `402` | The workspace's plan does not include API access. The token is paused, not revoked: it works again as soon as the plan includes API access. |
| `403` | The token does not have this endpoint's scope, it is a sandbox token, the workspace is suspended, or the request came from a network the workspace, or the token's IP allowlist, does not allow. |
| `422` | A field is missing or not in the form this endpoint takes. `detail` says which, and why. |
| `429` | This token has made more requests this minute than your plan allows. The Retry-After header says how many seconds to wait. |

```bash
curl -X POST "https://aicallstudio.com/api/v1/dnc" \
  -H "Authorization: Bearer mtc_YOUR_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"phone":"+919876543210"}'
```

### Take a number off Do-Not-Call

`DELETE /api/v1/dnc/{phone}` (scope `dnc:write`)

Take a number off your Do-Not-Call list, so it may be called again straight away. Do this only when the person asked to be called again: their opt-out is a legal obligation.

**Parameters**

| Parameter | Type | What it is |
| --- | --- | --- |
| `phone` (required) | string, in the path | — |
| `Idempotency-Key` | string, up to 255 characters, in the headers | Any unique text up to 255 characters, such as a UUID, chosen by you for this request. Sent again with the same body within 24 hours, the first answer comes back (with Idempotent-Replayed: true) and nothing is done twice. The same key with another body is refused with 422. |

**Answer (200): these fields**

| Field | Type | What it is |
| --- | --- | --- |
| `phone` (required) | string | — |
| `on_list` (required) | boolean | Whether the number is on the Do-Not-Call list now. |
| `changed` (required) | boolean | false when it already was (adding) or already was not (removing). |

**Errors**

| Code | When |
| --- | --- |
| `401` | The token is missing, unknown or revoked, or its workspace was deleted. |
| `402` | The workspace's plan does not include API access. The token is paused, not revoked: it works again as soon as the plan includes API access. |
| `403` | The token does not have this endpoint's scope, it is a sandbox token, the workspace is suspended, or the request came from a network the workspace, or the token's IP allowlist, does not allow. |
| `422` | A field is missing or not in the form this endpoint takes. `detail` says which, and why. |
| `429` | This token has made more requests this minute than your plan allows. The Retry-After header says how many seconds to wait. |

```bash
curl -X DELETE "https://aicallstudio.com/api/v1/dnc/9876543210" \
  -H "Authorization: Bearer mtc_YOUR_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)"
```
