Adds numbers to the blacklist. A blacklisted number receives neither promotional nor transactional messages.

## API URL

The URL used to send the HTTP requests:

```url
https://portal.bulkgate.com/api/1.0/black-list/add
```

> [!NOTE]
> If the request does not reach its destination, repeat it on the [backup server](https://www.bulkgate.com/en/docs/api-administration-tokens/api-backup-server/) `backup1.bulkgate.com`.

## Supported HTTP methods

- `POST` - `application/json`

```http
POST /api/1.0/black-list/add HTTP/1.1
Host: portal.bulkgate.com
Content-Type: application/json
```

## Parameters table

| PARAMETER NAME    | VALUE                                                   | MANDATORY | DEFAULT VALUE  |
|:------------------|:---------------------------------------------------------|:----------|:---------------|
| application_id    | [Application ID](https://www.bulkgate.com/en/docs/api-administration-tokens/api-administration/)           | **Yes**   | -              | 
| application_token | [Application authentication token](https://www.bulkgate.com/en/docs/api-administration-tokens/api-tokens/)	 | **Yes**   | -              |
| numbers           | Numbers to blacklist — an array, or a comma-separated string | **Yes** | -              |
| wallet            | Wallet on which to blacklist the numbers                | No        | Default wallet |
| source_id         | Identifier of the group of blacklisted numbers	         | No        | `api-<random string>` |
| reason            | Reason for the number being blacklisted	                 | No        | -              |
| type              | The list the numbers go to — `black-list` or `opt-out`  | No        | `black-list`   |

## Request example

```http-json
POST /api/1.0/black-list/add HTTP/1.1
Host: portal.bulkgate.com
Content-Type: application/json

{
  "application_id": 451,
  "application_token": "NKN02TWE6NfBkfl-your-secret-token-Wf05GaqLIWLW4aBj",
  "numbers": ["420123456789", "420987654321"],
  "wallet": "bg1905014138000023",
  "source_id": "api-my-import",
  "reason": "I don't want to receive business messages."
}
```

## Response

**In case of success:**

```json
{
    "data": {
        "message": "contacts have been blacklisted"
    }
}
```

**In case of error:**

```json
{
    "type": "invalid_wallet",
    "code": 400,
    "error": "Invalid wallet",
    "detail": null
}
```

```json
{
    "type": "no_valid_numbers",
    "code": 400,
    "error": "No valid numbers",
    "detail": null
}
```

```json
{
    "type": "number_already_exists",
    "code": 400,
    "error": "Number already exists",
    "detail": null
}
```

Where:

- **type** and **error** (description of the error) can be found in the [error types table](https://www.bulkgate.com/en/docs/api-administration-tokens/api-error-types/)
- **code** is the HTTP error code
- **detail** is additional information about the error

### Blacklist API error types

Besides the [general types](https://www.bulkgate.com/en/docs/api-administration-tokens/api-error-types/), the Blacklist API returns its own:

| TYPE                    | WHEN IT HAPPENS                                                    |
|:------------------------|:--------------------------------------------------------------------|
| `invalid_wallet`        | The given wallet does not exist or you have no access to it.        |
| `no_valid_numbers`      | The `numbers` parameter contains no valid number.                   |
| `number_already_exists` | You are sending a single number and it is already on the blacklist. |
