Removes a number from the blacklist, or a whole group of numbers by `source_id`.

## API URL

The URL used to send the HTTP requests:

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

> [!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/remove 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**                | -              |
| wallet            | Wallet from which to remove the blacklisted numbers     | No                     | Default wallet |
| number            | Number to be removed from the blacklist	                 | **Yes** or `source_id` | -              |
| source_id         | Identifier of the group of numbers to be removed	       | **Yes** or `number`    | -              |
| type              | The list the numbers are removed from — `black-list` or `opt-out` | No           | `black-list`   |

> [!NOTE]
> The `number` and `source_id` parameters cannot be combined — use exactly one of them.

## Request example

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

{
  "application_id": 451,
  "application_token": "NKN02TWE6NfBkfl-your-secret-token-Wf05GaqLIWLW4aBj",
  "wallet": "bg1905014138000023",
  "source_id": "api-my-import"
}
```

## Response

**In case of success:**

```json
{
    "data": {
        "message": "Black list contacts have been removed"
    }
}
```

**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": "missing_parameters",
    "code": 400,
    "error": "Missing parameters",
    "detail": null
}
```

```json
{
    "type": "use_number_or_source_id_not_both",
    "code": 400,
    "error": "Use number or source id not both",
    "detail": null
}
```

```json
{
    "type": "number_doesnt_exist",
    "code": 400,
    "error": "Number doesnt exist",
    "detail": null
}
```

```json
{
    "type": "invalid_number",
    "code": 400,
    "error": "Invalid number",
    "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`                 | None of the given numbers is valid.                      |
| `missing_parameters`               | Both `number` and `source_id` are missing.               |
| `use_number_or_source_id_not_both` | `number` and `source_id` were sent together.             |
| `number_doesnt_exist`              | The number is not on the blacklist.                      |
| `invalid_number`                   | `number` is not a valid phone number.                    |
