Get Your API Key
Navigate to Settings
Go to your dashboard and click on Settings → API
Generate API Key
Click “Generate New API Key” and copy it securely
Keep your API key secure! Never commit it to version control or expose it in client-side code.
Make Your First Request
Let’s fetch all your campaigns:
curl -X GET "https://server.smartlead.ai/api/v1/campaigns/?api_key=YOUR_API_KEY"
Create Your First Campaign
curl -X POST "https://server.smartlead.ai/api/v1/campaigns/new?api_key=YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "My First Campaign",
"track_settings": {
"track_open": true,
"track_click": true
}
}'
Add Email Account
Before sending emails, you need to add at least one email account:
curl -X POST "https://server.smartlead.ai/api/v1/email-accounts/save?api_key=YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"from_name": "John Doe",
"from_email": "john@example.com",
"user_name": "john@example.com",
"password": "your_email_password",
"smtp_host": "smtp.example.com",
"smtp_port": 587,
"imap_host": "imap.example.com",
"imap_port": 993,
"max_email_per_day": 50,
"warmup_enabled": true,
"total_warmup_per_day": 20,
"daily_rampup": 2,
"reply_rate_percentage": 30
}'
Add Leads to Campaign
Now add some leads to your campaign:
import requests
api_key = "YOUR_API_KEY"
campaign_id = 123 # Replace with your campaign ID
url = f"https://server.smartlead.ai/api/v1/campaigns/{campaign_id}/leads"
leads = [
{
"first_name": "Jane",
"last_name": "Doe",
"email": "jane.doe@example.com",
"company_name": "Acme Corp",
"custom_fields": {
"job_title": "CEO",
"industry": "Technology"
}
},
{
"first_name": "John",
"last_name": "Smith",
"email": "john.smith@techco.com",
"company_name": "Tech Co",
"custom_fields": {
"job_title": "CTO"
}
}
]
response = requests.post(
url,
params={"api_key": api_key},
json={"lead_list": leads}
)
result = response.json()
print(f"Added {result['added_count']} leads successfully")
Create Email Sequences
Add email sequences to your campaign:
import requests
api_key = "YOUR_API_KEY"
campaign_id = 123
url = f"https://server.smartlead.ai/api/v1/campaigns/{campaign_id}/sequences"
sequences = [
{
"seq_number": 1,
"subject": "Quick question about {{company_name}}",
"email_body": "Hi {{first_name}},\n\nI noticed {{company_name}} is...",
"seq_delay_details": {
"delay_in_days": 0
}
},
{
"seq_number": 2,
"subject": "Following up - {{company_name}}",
"email_body": "Hi {{first_name}},\n\nFollowing up on my previous email...",
"seq_delay_details": {
"delay_in_days": 3
}
}
]
response = requests.post(
url,
params={"api_key": api_key},
json={"sequences": sequences}
)
print("Sequences created successfully!")
Start Your Campaign
Finally, start your campaign:
curl -X PATCH "https://server.smartlead.ai/api/v1/campaigns/123/status?api_key=YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"status": "ACTIVE"}'
Congratulations! Your first campaign is now running. You can monitor its performance in the dashboard or via the analytics API.
What’s Next?
Need Help?