---
title: "Mass assign leads"
method: PUT
path: "/{sub_domain}/api/campaign-leads/mass-assign"
tags: ["Campaign-Leads"]
---

# Mass assign leads

`PUT /{sub_domain}/api/campaign-leads/mass-assign`

## Request

- Base URL: `https://api.commpeak.com/dialer`
- URL: `https://api.commpeak.com/dialer/{sub_domain}/api/campaign-leads/mass-assign`
- Auth: API key in header `Authorization`

Assign many leads to a campaign in a single request.

**When to use.** Bulk-add leads to a campaign, selecting them by a filter instead of one at a time. To take leads off a campaign, use `PUT /campaign-leads/mass-unassign`.

**Parameters.**

- `campaign_id` (integer, required): the campaign to assign the matched leads to.
- `where` (object, required): conditions that select the leads to assign. Any lead field may be used, and each value may be a single value (exact match) or an array (matches any of the listed values). Common fields are `id`, `first_name`, `last_name`, `phone`, `email`, `city`, `state`, `zip`, `original_identifier`.
- `remove_from_others` (boolean): when true, the matched leads are also removed from every other campaign.

**Returns.** `{ "leads": { "<campaign-lead id>": { ...lead }, "errors": [ ... ] } }`. Successfully assigned leads are keyed by the new campaign-lead ID, and any leads that could not be assigned are collected under `errors`.

**Example.**

```json
{ "campaign_id": 12, "remove_from_others": true, "where": { "id": [1, 2, 3] } }
```

## Path parameters

- `sub_domain` string, required: Dialer Name (subdomain)

## Request body

- MassAssignInput
  - `where` IdsWhereClause, required
    - `id` unknown[], nullable: Lead IDs.
      - unknown
  - `campaign_id` integer, required: Campaign to assign the matched leads to.
  - `remove_from_others` boolean, nullable: Remove the matched leads from other campaigns (true = remove, false = skip).

## Response `200`

Successful Response

- MassAssignResponse
  - `leads` object, required: Map of campaign-lead ID to the assigned lead. Also contains an "errors" array for leads that failed to assign.

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/commpeak/apis/commpeak-dialer-api.md) - [All operations](https://skmtc.dev/commpeak/apis/commpeak-dialer-api/llms.txt) - [OpenAPI document](https://skmtc.dev/commpeak/apis/commpeak-dialer-api/revisions/18c5edc07544?raw)
