Updated March 5, 2026
TL;DR: Choose an API built for your use case. Transactional APIs (SendGrid, Mailgun) ban cold outreach and will suspend your account. Authenticate your domains first. Publish SPF, DKIM, and DMARC records and wait 48 hours before your first send. For agencies scaling outreach, Instantly's API manages unlimited inboxes on a flat fee with no per-email charges or separate warmup tools. Warm every inbox for at least 30 days, ramp gradually from 5 sends per day to the 30-per-day cap, and keep bounce rate at or below 1%.
Building email automation into your agency stack is straightforward once you choose the right API for the job. The problem is that most guides assume you're sending password resets, but agencies running multi-touch outreach sequences need purpose-built cold email software, and the wrong API choice costs you deliverability, margins, or both

Core concepts: how email APIs differ from SMTP
REST API vs. SMTP: what actually changes
SMTP uses a conversational protocol that adds latency at scale because every send requires multiple round-trip commands between your client and the mail server. According to SparkPost's performance comparison, REST API delivery is faster and requires fewer client-side resources because it skips the handshake overhead.
APIs require less back-and-forth communication for approval, which directly reduces the chance of a sending error at volume. REST APIs also authenticate via API key rather than a basic username and password, which is a meaningful security improvement. The debounce.io comparison adds a practical point: SMTP setup requires no coding knowledge, but REST APIs are the right choice for any automated workflow at agency scale.
Transactional, marketing, and cold email APIs
Choosing the right API type is your most important decision before writing a single line of code, because the wrong choice means a suspended account and zero pipeline.
API type | Primary use case | Examples | Cold email allowed? |
|---|---|---|---|
Transactional | Password resets, receipts, notifications | SendGrid, Mailgun, Postmark | No |
Marketing | Opt-in newsletters, promotional sends | Mailchimp, ConvertKit | No |
Cold email / outreach | Sales sequences, lead nurturing at scale | Instantly | Yes |
SendGrid's acceptable use policy explicitly prohibits "sending unsolicited or unwanted emails in bulk" and bans sending to addresses scraped from the internet or social media. Their opt-in requirements page reinforces that every recipient must have given affirmative consent. Cold email by definition lacks that prior relationship, so using SendGrid for outreach violates their ToS and leads to account suspension.
As Instantly's 2026 email API comparison explains, the correct architecture for agencies is to split the stack: use a transactional API for app-triggered notifications and a cold email API like Instantly for outreach sequences.
Instantly's API is a programmatic campaign management API. You add leads, manage sequences, read analytics, and configure webhooks. The platform handles delivery routing, warmup, and account rotation on the backend.

Prerequisites for a secure API setup
Domain authentication: SPF, DKIM, and DMARC
You must configure three DNS records before your first send. Without them, receiving servers treat your mail as potentially spoofed and deliverability drops immediately.
- SPF (Sender Policy Framework): A DNS TXT record that lists which servers are authorized to send mail for your domain. A standard Google Workspace SPF record looks like:
v=spf1 include:_spf.google.com ~all. SPF can take up to 48 hours to start working after you publish the record. - DKIM (DomainKeys Identified Mail): A cryptographic signature added to outgoing mail that verifies the message came from your domain and wasn't altered in transit. Your email provider generates a public/private key pair, and you publish the public key as a DNS TXT record.
- DMARC: Tells receiving servers what to do when SPF or DKIM fails. The three policy options are
reject,quarantine, ornone(monitor only). A common starting record is:v=DMARC1; p=none; rua=mailto:your-email@yourdomain.com. Set up DKIM and SPF at least 48 hours before enabling DMARC so both are authenticating messages cleanly first.
API key management
Never hardcode an API key in your source code. If the repository is public or accidentally shared, the key is compromised immediately. OpenAI's API key best practices are direct: "Store them in environment variables or in files outside of your application's source tree."
Anthropic's key safety guidelines and GitGuardian's secrets management guide both recommend rotating API keys every 90 days and using a dedicated secrets manager like HashiCorp Vault or AWS Secrets Manager in production. Strac's key storage guide confirms that centralized key management systems provide the tightest access control for team environments.
To get your Instantly API key, navigate to Settings > Integrations > API at app.instantly.ai/app/settings/integrations. The Instantly API V2 help article confirms that Instantly supports multiple API keys with specific scopes, so you can issue a read-only key to a junior dev and a full-access key to your automation system, then revoke either independently.

Webhook endpoint preparation
Webhooks push real-time event data to your application when a lead replies, bounces, unsubscribes, or books a meeting. Before you configure a webhook in the Instantly dashboard, you need a publicly accessible HTTPS endpoint ready to receive POST requests:
// Node.js webhook listener example
const express = require('express');
const app = express();
app.use(express.json());
app.post('/webhook/instantly', (req, res) => {
const { event_type, campaign_id, campaign_name } = req.body;
console.log(`Event: ${event_type} | Campaign: ${campaign_name}`);
// Route to CRM, Slack, or database based on event_type
res.sendStatus(200);
});
app.listen(3000, () => console.log('Webhook listener running on port 3000'));
Step-by-step email API integration guide
Step 1: Obtain your credentials
Go to Settings > Integrations > API inside your Instantly dashboard. Generate a new API key and store it immediately in your secrets manager or as an environment variable. Instantly API V2 uses Bearer token authentication for all requests, which is more secure than the V1 approach per the Instantly API V2 help article.
Step 2: Configure sender accounts
Connect your sending accounts inside the dashboard first (Gmail/Google Workspace or SMTP/IMAP). Once connected, accounts are enrolled in Instantly's warmup network, which runs in the background and maintains positive engagement signals even while your campaign sends are active. The cold email setup walkthrough shows the full process visually if you prefer video.
Step 3: Construct the API payload
The Instantly Leads endpoint accepts a JSON payload to add a lead to a campaign programmatically. Working examples in both Python and Node.js:
Python (using requests)
import requests
import os
# Never hardcode the API key. Pull from environment variable.
api_key = os.environ.get('INSTANTLY_API_KEY')
url = 'https://api.instantly.ai/api/v2/leads'
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
payload = {
'email': 'lead@example.com',
'first_name': 'Jane',
'last_name': 'Smith',
'company_name': 'Acme Corp',
'campaign_id': 'your-campaign-uuid-here',
'custom_variables': {
'industry': 'SaaS',
'past_customer': False,
'persona': 'VP of Sales'
}
}
response = requests.post(url, json=payload, headers=headers)
# Check status before processing
if response.status_code == 200:
print('Lead added:', response.json())
else:
print(f'Error {response.status_code}:', response.text)
Node.js (using axios)
const axios = require('axios');
const apiKey = process.env.INSTANTLY_API_KEY;
const url = 'https://api.instantly.ai/api/v2/leads';
const payload = {
email: 'lead@example.com',
first_name: 'Jane',
last_name: 'Smith',
company_name: 'Acme Corp',
campaign_id: 'your-campaign-uuid-here',
custom_variables: {
industry: 'SaaS',
past_customer: false,
persona: 'VP of Sales'
}
};
axios.post(url, payload, {
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
}
})
.then(res => console.log('Lead added:', res.data))
.catch(err => console.error(
'Error:', err.response ? err.response.data : err.message
));

Step 4: Handle the response
Every API response returns an HTTP status code that tells you what happened. Handle these five explicitly:
- 200 OK: Request succeeded. Parse the JSON body for the lead or campaign data.
- 401 Unauthorized: Your API key is missing, invalid, or expired. Do not retry. Verify the key format (
Authorization: Bearer YOUR_KEY), check for copy errors, and regenerate via Settings > Integrations > API if needed. - 403 Forbidden: Key is valid but lacks permission for this endpoint. Check your key scopes in the dashboard.
- 429 Too Many Requests: You've exceeded the rate limit. Retry with exponential backoff and respect the
Retry-Afterheader. - 500 Internal Server Error: Server-side issue. Retry with backoff. The request itself is not the problem.
According to MDN's HTTP status reference and Postman's status code guide, the correct retry strategy is to retry 5xx errors and 429 responses with exponential backoff (1s, 2s, 4s, 8s). Never retry other 4xx errors because the request itself is the problem and retrying returns the same error.
import time
import requests
import os
def add_lead_with_retry(payload, max_retries=3):
api_key = os.environ.get('INSTANTLY_API_KEY')
url = 'https://api.instantly.ai/api/v2/leads'
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
for attempt in range(max_retries):
response = requests.post(url, json=payload, headers=headers)
if response.status_code == 200:
return response.json()
elif response.status_code == 401:
raise Exception('Authentication failed. Check your API key.')
elif response.status_code == 429 or response.status_code >= 500:
wait = 2 ** attempt # 1s, 2s, 4s
print(f'Retrying in {wait}s (attempt {attempt + 1})...')
time.sleep(wait)
else:
raise Exception(f'Request failed: {response.status_code} {response.text}')
raise Exception('Max retries exceeded.')
Step 5: Set up webhooks for reply tracking
Webhooks let Instantly push event data to your CRM or notification system the moment a lead replies, bounces, unsubscribes, or books a meeting. You don't need to poll the API.
To configure a webhook: go to Integrations > Webhooks, click Add Webhook, enter your listener URL, select the campaign, and choose your event types. Per the Instantly webhooks documentation, available event types include reply_received, email_bounced, email_opened, lead_unsubscribed, meeting_booked, campaign_completed, and nine more.
Webhook access requires a Hypergrowth plan or above. The API and webhooks guide shows how to use Make's native Instantly modules to route events to HubSpot, Pipedrive, or Slack without additional code.
For Zapier-based workflows, pre-built recipes include Pipedrive lead sync, HubSpot contact creation, Close CRM push, Slack reply notifications, and Google Sheets Zapier integration for pulling interested leads into a spreadsheet.
Agency focus: scaling to unlimited accounts without API bloat
How Instantly's unlimited accounts simplify scaling
Per-seat pricing is the biggest margin killer for agencies running cold email. Apollo's Basic plan starts at $59 per user per month, reaching $149 per seat on the Organization plan. If you manage 10 clients with 5 sending inboxes each, that's 50 seats of cost whether or not you need Apollo's data features.
Instantly's flat-fee agency pricing guide confirms that every Outreach tier includes unlimited email accounts and unlimited warmup, so your base cost doesn't rise as you add client inboxes. The Hypergrowth plan at $97 per month covers 100,000 emails across unlimited accounts. The math is direct:
Cost comparison for 50 sending inboxes
Setup | Monthly cost |
|---|---|
Instantly Hypergrowth (50 inboxes) | $97 flat |
Apollo Basic (50 seats) | $2,950 |
Apollo Professional (50 seats) | $4,950 |
For multi-client management via API, each API call uses Bearer authentication against your workspace. You can programmatically create campaigns, add leads to specific campaigns, and read per-campaign analytics without creating separate accounts per client. The unlimited outreach pricing guide covers how stacking plans compares to per-seat alternatives across different agency sizes.
Ensuring deliverability with built-in warmup
Sending is easy. Landing in the primary inbox is where most API integrations fail. Instantly's warmup network runs automatically on every connected account, sending controlled positive-interaction emails within a private network to build trust signals with major inbox providers. It continues running during your active campaign sends to buffer any negative signals from cold outreach.
"This tool automatically mimics human behavior... ensuring emails land in the primary inbox rather than spam." - lucky b. on G2
The cold email deliverability guide from Instantly's channel covers the full warmup and ramp framework.
Key rule: do not scale past 30 emails per inbox per day. Ramp gradually from 5 sends per day toward that cap, and keep your bounce rate at or below 1%. If health scores drop, pause the campaign, re-verify your list, and restart at a lower cap.
Comparing top email API providers for developers
Provider | Pricing model | Cold email? | Warmup included? |
|---|---|---|---|
Instantly | Flat fee, unlimited accounts | Yes | Yes, unlimited |
SendGrid | Per-email tiers | No (ToS violation) | No |
Mailgun | Per-email tiers | No (ToS violation) | No |
Apollo | Per seat per month | No (restricted) | No (SendGrid integration) |
Both SendGrid and Mailgun price by email volume with cold outreach explicitly prohibited. Apollo's per-seat model, detailed in Cognism's Apollo pricing breakdown, makes it impractical for agencies managing multiple inboxes because costs scale with headcount rather than with volume. The Instantly vs. competitors analysis adds more context on how the toolset compares for agency use cases.
"I appreciate Instantly for its intelligent handling of domain and mailbox rotation as well as provider matching, which is critical for ensuring that my emails land directly in the primary inbox instead of getting caught in spam filters." - Richard E. on G2
"It allows me to scale my outreach without losing personalization and effectively keeps my campaigns organized." - Mattia G. on G2
Security best practices and troubleshooting common errors
Common setup pitfalls and solutions
401 Unauthorized:
Your API key is incorrect, missing, or the format is wrong. The correct header format is Authorization: Bearer YOUR_KEY_HERE. Verify there are no extra characters introduced during copy-paste, then regenerate via Settings > Integrations > API if the issue persists.
Emails sent but not delivered:
This is almost always a DNS authentication issue. Use MXToolbox to verify your SPF, DKIM, and DMARC records are correctly published and have propagated. As Mailtrap's deliverability guide notes, DKIM failures are often intermittent and caused by single-character DNS typos or mismatched selectors when multiple systems sign the same outgoing message.
429 Too Many Requests:
You've exceeded the rate limit. Implement exponential backoff (1s, 2s, 4s, 8s delays) and respect the Retry-After header in the response. If you're consistently hitting this limit, distribute sends across more accounts rather than increasing the rate cap.
DNS propagation failures:
DNS changes take 24-48 hours to propagate globally, so wait a full 48 hours before debugging authentication failures. Verify you used the correct record type, since DKIM records use CNAME at some providers and TXT at others, and a type mismatch is a common silent failure. The Instantly API troubleshooting guide and SendGrid troubleshooting reference both cover these patterns in detail.
Bounces exceeding 1%:
Pause the campaign immediately and re-verify your list before resuming. Mailtrap reports that spam complaint rates above 0.3% reduce inbox placement materially. For an end-to-end look at diagnosing deliverability drops, the best cold email setup video from Instantly covers the full framework.
API setup checklist {#api-setup-checklist}
Use this checklist before your first API send:
- SPF record published and verified with MXToolbox
- DKIM record published and verified
- DMARC record set to
p=nonefor monitoring initially - 48-hour DNS propagation wait completed
- API key stored in environment variable, not in source code
- API key scopes set to minimum required permissions
- Key rotation reminder set for 90 days
- Webhook listener URL live and returning 200
- Email accounts connected and warmup enabled in Instantly dashboard
- Warmup enabled and running for around 14 days before first campaign send
- Send cap set to 5 emails per inbox per day for week one
- Bounce rate monitoring enabled with a 1% pause threshold
- Error handling with exponential backoff implemented in code
For a step-by-step visual of the platform setup, the n8n and Instantly automation video shows how to connect the API into a broader no-code workflow.
"Switching to Instantly from apollo.ai, which frequently crashed, has been a smooth experience, and the platform is working very fine for us now." - mohammad s. on G2
Wrap up and next steps
You have the full technical picture: domain authentication, API key management, working Python and Node.js integrations for adding leads programmatically, error handling with exponential backoff, and webhook configuration for real-time reply routing. The infrastructure layer, warmup, account rotation, and deliverability monitoring, runs inside Instantly so your team focuses on sequence logic and copy instead of mail server maintenance.
The one constraint to respect before you scale: warm every inbox for at least 30 days, ramp gradually from 5 sends per day toward the 30-per-day maximum, and keep bounce rate at or below 1%. Volume without warmup is the fastest way to burn a domain and explain to a client why their pipeline went quiet.
Ready to build your outreach engine? Try Instantly free, generate your API key from the Integrations tab. The API V2 help article has the full endpoint reference, and this complete platform review walks through every feature if you're evaluating for a client build.
Frequently asked questions
Can I use SendGrid for cold email outreach?
No. SendGrid's terms of service explicitly prohibit sending unsolicited bulk email and require affirmative opt-in from every recipient. Cold outreach campaigns violate these terms and result in account suspension.
What is the difference between an email sending API and an email verification API?
An email sending API delivers messages to recipients via campaign sequences or programmatic lead management, while a verification API checks whether addresses are valid and deliverable before you send. Use both in sequence: verify your list first to reduce bounces, then send through your outreach API.
How do I handle rate limits in Python?
Catch HTTP 429 responses and implement exponential backoff by sleeping for 2 ** attempt seconds between retries, starting at 1 second. The code example in Step 4 shows this pattern with the requests library.
Does Instantly's API support attachments?
Yes. The API schema documentation covers the attachments field structure, which requires a hosted file URL rather than inline base64 data.
Which Instantly plan is required for webhook access?
Webhook access requires Hypergrowth or above, while API V2 endpoints work on Growth and above. Full plan details are in the Instantly webhooks help article.
How do I add leads from a Google Sheet to a campaign automatically?
Use the Google Sheets Zapier integration or call the Instantly API directly from a Google Apps Script that reads rows and posts to the v2/leads endpoint on a schedule.
Key terms glossary
REST API: An Application Programming Interface that uses standard HTTP methods (GET, POST, PUT, DELETE) and JSON data format for communication between systems. Faster and more scalable than SMTP for high-volume automation.
Webhook: A mechanism where your application receives real-time POST requests from a third-party platform when specific events occur, such as a reply or a bounce, without polling.
JSON: JavaScript Object Notation, a lightweight text format for structuring API request and response data. All Instantly API payloads use JSON.
SMTP: Simple Mail Transfer Protocol, the foundational standard for sending email between servers using a conversational text-based command sequence. Slower than REST APIs at volume and requires persistent connections.
Rate limiting: A control mechanism that caps how many API requests a client can make within a specific time window. Exceeded limits return a 429 status code and require exponential backoff before retrying.
Endpoint: A specific URL where an API resource can be accessed. For example, https://api.instantly.ai/api/v2/leads is the endpoint for lead management operations.
Payload: The data body of an API request or response, typically formatted as JSON. Contains the fields and values your application sends to or receives from the API.
Warmup: A process where new sending accounts build sender reputation gradually through controlled, positive-interaction email exchanges before cold outreach campaigns start. Skipping warmup risks spam blocks that sideline the account for days.
Sender reputation: A score assigned to your sending domain and IP by inbox providers, based on engagement signals, bounce rates, spam complaints, and authentication status. It directly determines inbox placement.
DKIM: DomainKeys Identified Mail, a cryptographic email authentication method that adds a digital signature to outgoing messages, letting receiving servers verify the message came from your domain and wasn't altered in transit.