curl -X POST "https://server.smartlead.ai/api/v1/campaigns/123/reallocate-mailboxes?api_key=YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"from_email_account_ids": [3703387, 3703397]
}'
import requests
API_KEY = "YOUR_API_KEY"
campaign_id = 123
response = requests.post(
f"https://server.smartlead.ai/api/v1/campaigns/{campaign_id}/reallocate-mailboxes",
params={"api_key": API_KEY},
json={"from_email_account_ids": [3703387, 3703397]} # or {} for all removed mailboxes
)
result = response.json()
if result.get('ok'):
print(f"Moved {result['leads_reallocated']} leads")
const API_KEY = 'YOUR_API_KEY';
const campaignId = 123;
const response = await fetch(
`https://server.smartlead.ai/api/v1/campaigns/${campaignId}/reallocate-mailboxes?api_key=${API_KEY}`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ from_email_account_ids: [3703387, 3703397] }) // or {} for all removed mailboxes
}
);
const result = await response.json();
if (result.ok) {
console.log(`Moved ${result.leads_reallocated} leads`);
}
{
"ok": true,
"leads_reallocated": 5,
"to_email_account_ids": [2568043]
}
{
"error": "No email accounts are attached to this campaign."
}
{
"error": "Email account(s) 2568043 still attached to this campaign. Only leads on mailboxes removed from the campaign can be reallocated."
}
{
"error": "Campaign not found - Invalid campaign_id."
}
{
"error": "Failed to reallocate mailboxes. Please try again later."
}
Campaign Management
Reallocate Mailboxes
Move leads off mailboxes that were removed from a campaign onto the campaign’s attached mailboxes
POST
/
api
/
v1
/
campaigns
/
{campaign_id}
/
reallocate-mailboxes
curl -X POST "https://server.smartlead.ai/api/v1/campaigns/123/reallocate-mailboxes?api_key=YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"from_email_account_ids": [3703387, 3703397]
}'
import requests
API_KEY = "YOUR_API_KEY"
campaign_id = 123
response = requests.post(
f"https://server.smartlead.ai/api/v1/campaigns/{campaign_id}/reallocate-mailboxes",
params={"api_key": API_KEY},
json={"from_email_account_ids": [3703387, 3703397]} # or {} for all removed mailboxes
)
result = response.json()
if result.get('ok'):
print(f"Moved {result['leads_reallocated']} leads")
const API_KEY = 'YOUR_API_KEY';
const campaignId = 123;
const response = await fetch(
`https://server.smartlead.ai/api/v1/campaigns/${campaignId}/reallocate-mailboxes?api_key=${API_KEY}`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ from_email_account_ids: [3703387, 3703397] }) // or {} for all removed mailboxes
}
);
const result = await response.json();
if (result.ok) {
console.log(`Moved ${result.leads_reallocated} leads`);
}
{
"ok": true,
"leads_reallocated": 5,
"to_email_account_ids": [2568043]
}
{
"error": "No email accounts are attached to this campaign."
}
{
"error": "Email account(s) 2568043 still attached to this campaign. Only leads on mailboxes removed from the campaign can be reallocated."
}
{
"error": "Campaign not found - Invalid campaign_id."
}
{
"error": "Failed to reallocate mailboxes. Please try again later."
}
This is the API equivalent of the Reallocate Mailboxes button in the app. Use it after removing email accounts from a campaign so their leads keep sending from a mailbox that is still attached.
Overview
When an email account is removed from a campaign, leads already assigned to it stay on that account. This endpoint finds those leads (and leads with no mailbox assigned) and assigns each one to a randomly chosen mailbox that is currently attached to the campaign. Behavior:- Only moves leads whose mailbox is not attached to the campaign, or is empty
- Leads with status
STARTEDare not moved - Each moved lead gets a random attached mailbox
- Runs synchronously: the response is sent after all leads are moved
- Safe to repeat: a second call returns
leads_reallocated: 0once nothing is left to move
Path Parameters
number
required
The campaign ID
Query Parameters
string
required
Your SmartLead API key
Body Parameters (optional)
number[]
Optional. Only move leads that are on these email accounts. 1 to 100 unique email account IDs. Every ID must be an account that is no longer attached to the campaign, otherwise the request fails with
400.Omit this field (or send an empty body {}) to move leads off all removed mailboxes.Example: [3703387, 3703397]curl -X POST "https://server.smartlead.ai/api/v1/campaigns/123/reallocate-mailboxes?api_key=YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"from_email_account_ids": [3703387, 3703397]
}'
import requests
API_KEY = "YOUR_API_KEY"
campaign_id = 123
response = requests.post(
f"https://server.smartlead.ai/api/v1/campaigns/{campaign_id}/reallocate-mailboxes",
params={"api_key": API_KEY},
json={"from_email_account_ids": [3703387, 3703397]} # or {} for all removed mailboxes
)
result = response.json()
if result.get('ok'):
print(f"Moved {result['leads_reallocated']} leads")
const API_KEY = 'YOUR_API_KEY';
const campaignId = 123;
const response = await fetch(
`https://server.smartlead.ai/api/v1/campaigns/${campaignId}/reallocate-mailboxes?api_key=${API_KEY}`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ from_email_account_ids: [3703387, 3703397] }) // or {} for all removed mailboxes
}
);
const result = await response.json();
if (result.ok) {
console.log(`Moved ${result.leads_reallocated} leads`);
}
Response Fields
boolean
true when the request completednumber
Number of leads moved to an attached mailbox.
0 when there was nothing to move.number[]
All email accounts currently attached to the campaign, i.e. the pool leads were distributed across. A given account may not have received any leads.
Response Codes
Success
Leads reallocated (or nothing to reallocate)
Bad Request
The campaign has no email accounts attached, an ID in
from_email_account_ids is still attached to the campaign, or the request failed validation (unknown body field, duplicate or non-integer IDs, more than 100 IDs)Unauthorized
Invalid or missing API key
Not Found
Campaign not found or does not belong to your account
Internal Server Error
Server error occurred. Please try again or contact support if the issue persists.
{
"ok": true,
"leads_reallocated": 5,
"to_email_account_ids": [2568043]
}
{
"error": "No email accounts are attached to this campaign."
}
{
"error": "Email account(s) 2568043 still attached to this campaign. Only leads on mailboxes removed from the campaign can be reallocated."
}
{
"error": "Campaign not found - Invalid campaign_id."
}
{
"error": "Failed to reallocate mailboxes. Please try again later."
}
Attach at least one replacement mailbox with Add Email Accounts before calling this endpoint. Mailboxes that are disconnected but still attached to the campaign are not affected; remove them from the campaign first.
Related Endpoints
- Get Campaign Email Accounts - See which mailboxes are attached
- Add Email Accounts - Attach replacement mailboxes
- Remove Email Accounts - Detach mailboxes from the campaign
- Update Lead Email Account - Move a single lead to a specific mailbox
