> ## Documentation Index
> Fetch the complete documentation index at: https://api.smartlead.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Assign Client to Campaign

> Assign a campaign to a client (or remove its client), optionally applying the client's DNC list

> [!NOTE]
>
> Requires your own API key. Client API keys get `401`.
>
> Assigning a client also:
>
> * replaces the campaign's SmartServer assignments with the new client's SmartServers
> * sets the client on the campaign and its subsequences
> * shares the campaign's leads with the new client
>
> Sub-sequence campaigns cannot be assigned directly. Assign the parent campaign instead.

## Query Parameters

**api\_key** `string` *required*

Your SmartLead API key

## Request Body

**campaignId** `number` *required*

Campaign ID

**clientId** `number | null`

Client ID to assign. Use `null` to remove the campaign's client.

**applyClientDNC** `boolean | null`

When `true` and `clientId` is set, the client's DNC (block list) is applied to the campaign

```bash cURL theme={null}
curl -X POST "https://server.smartlead.ai/api/v1/campaigns/assign-client?api_key=YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"campaignId": 123, "clientId": 456, "applyClientDNC": true}'
```

```python Python theme={null}
import requests

response = requests.post(
    "https://server.smartlead.ai/api/v1/campaigns/assign-client",
    params={"api_key": "YOUR_API_KEY"},
    json={"campaignId": 123, "clientId": 456, "applyClientDNC": True}
)
print(response.json())
```

## Response Example

```json 200 theme={null}
{
  "ok": true,
  "message": "success",
  "client": {
    "id": 456,
    "email": "client@example.com"
  }
}
```

```json 200 - Client removed (clientId null) theme={null}
{
  "ok": true,
  "message": "success",
  "client": null
}
```

```json 500 - Error theme={null}
{
  "message": "Invalid client Id!"
}
```

Possible `message` values on error: `Invalid campaign Id!`, `Cannot assign client to a sub sequence!`, `Cannot assign the same client to the campaign`, `Invalid client Id!`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.