Adds an OAuth-authenticated email account (Gmail or Outlook). SmartLead manages token refresh automatically. Use this endpoint after obtaining OAuth tokens from the respective provider.
Query Parameters
Request Body
Display name for outgoing emails
Email address (must match OAuth account)
Email username (typically same as from_email)
Provider type. Valid values: GMAIL, OUTLOOK
OAuth token object obtained from provider Token type, must be Bearer
OAuth refresh token for automatic renewal
Token expiry timestamp (Unix timestamp in milliseconds)
OpenID Connect ID token (optional)
Token expiry ISO string (optional)
Seconds until token expires (optional)
Extended expiry time for Microsoft tokens (optional)
Whether to enable email warmup for this account
use_whitelabel_credentials
Whether to use whitelabel OAuth credentials. Must be true or false
Email account ID (only for updates, null for new accounts)
Maximum emails allowed per day (including warmup and campaigns)
Custom domain for tracking links
BCC email address for all outgoing emails
Minimum time to wait between emails in minutes
Number of warmup emails per day (if warmup_enabled is true)
Daily increase in warmup email count
Target reply rate percentage for warmup
Client ID for multi-tenant accounts
curl -X POST "https://server.smartlead.ai/api/v1/email-accounts/save-oauth?api_key=YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"from_name": "John Doe",
"from_email": "john@gmail.com",
"username": "john@gmail.com",
"type": "GMAIL",
"token": {
"scope": "https://mail.google.com/",
"token_type": "Bearer",
"access_token": "ya29.a0AfH6SMBx...",
"refresh_token": "1//0gvJf9X...",
"expiry_date": 1732627200000
},
"warmup_enabled": true,
"use_whitelabel_credentials": true,
"total_warmup_per_day": 20,
"daily_rampup": 2,
"max_email_per_day": 50
}'
Response Codes
OAuth email account added successfully
Invalid OAuth token or connection validation failed
Invalid or missing API key
Missing required fields or invalid type value
200 - Success
401 - Unauthorized
422 - Validation Error
400 - Token Error
{
"ok" : true ,
"message" : "OAuth account added successfully" ,
"data" : {
"id" : 123 ,
"from_email" : "john@gmail.com" ,
"type" : "GMAIL" ,
"is_smtp_success" : true ,
"is_imap_success" : true
}
}
OAuth Flow
Obtain OAuth tokens from provider
Use Google or Microsoft OAuth flow to obtain access and refresh tokens with appropriate mail scopes. Gmail Scope Required: https://mail.google.com/Outlook Scope Required: https://outlook.office.com/.default or https://outlook.office.com/SMTP.Send https://outlook.office.com/IMAP.AccessAsUser.All
Call this endpoint with tokens
Send the OAuth tokens and account information to this endpoint. SmartLead will validate the connection.
Enable warmup if needed
Set warmup_enabled: true and configure warmup parameters to gradually build sender reputation.
Usage Notes
OAuth tokens must be fresh and have the correct mail scopes. Expired tokens will cause connection failures.
Use use_whitelabel_credentials: true to leverage SmartLead’s OAuth app for Gmail/Outlook. This simplifies the OAuth flow as you don’t need to create your own OAuth application.
SmartLead automatically refreshes expired OAuth tokens using the refresh_token. Ensure the refresh_token is included in the token object.