API Key Best Practices
🔐 Secure and manage your Mailchimp API keys effectively. Follow these best practices to protect your account and ensure smooth operation.
What You'll Learn
- How to store API keys securely
- When and how to rotate keys
- Security best practices
- Troubleshooting key issues
Time: 5 minutes
Difficulty: Intermediate
Security Best Practices
Use Read-Only Keys When Possible
For testing and exploration, create read-only API keys:
- Limits what can be accessed if compromised
- Perfect for AI Analyst (free tier) usage
- Reduces risk of accidental changes
How to create: In Mailchimp, create a new API key and restrict permissions to read-only operations.
Store Keys Securely
Do This
- Store in
.envfile (not committed to git) - Use environment variables
- Enable disk encryption on your computer
- Use password manager for key storage
Don't Do This
- Commit API keys to version control
- Share keys in emails or messages
- Store in plain text files
- Share keys with unauthorized users
Rotate Keys Periodically
Best Practice: Rotate API keys every 90 days or:
- After any suspected compromise
- When team members leave
- After security incidents
- When switching between accounts
How to rotate:
- Create a new API key in Mailchimp
- Update your
.envfile - Restart Claude Desktop
- Revoke the old key in Mailchimp
Use Separate Keys for Different Accounts
If managing multiple Mailchimp accounts:
- Use separate API keys for each account
- Don't share keys between accounts
- Restart Claude Desktop when switching keys
Restart After Changing Keys
Critical: Always restart Claude Desktop completely after changing API keys to clear cached resources.
Key Management by Role
For Marketers (AI Analyst)
- Use read-only API keys for analysis
- Perfect for exploring data safely
- No risk of accidental changes
For Account Managers
- Use separate keys for each client account
- Enable PII masking with sensitive accounts
- Rotate keys regularly for client accounts
- Use read-only keys for initial account reviews
For Business Owners
- Use full-access keys for campaign creation
- Store keys securely on your machine
- Rotate keys if shared with team members
Environment Variables Setup
Recommended Configuration
Create a .env file in your home directory or project directory:
MAILCHIMP_API_KEY=your-api-key-here
MAILCHIMP_SERVER_PREFIX=us9
MAILCHIMP_MASK_PII=true # Optional, for sensitive accounts
Loading Environment Variables
The MCP server automatically loads from:
.envfile in current directory- System environment variables
- Configuration file
Key Permissions
Read-Only Operations (AI Analyst)
- View audiences and campaigns
- Access campaign reports
- Read member information
- View templates and settings
Write Operations (AI Marketer + Account Manager)
- Create and send campaigns
- Manage members and segments
- Update audience information
- Create and edit templates
- Manage automation workflows
Troubleshooting API Key Issues
Key Not Working
Check:
- API key format is correct (
abc123-us9) - Key hasn't been revoked in Mailchimp
- Server prefix matches your account region
- Key has necessary permissions
Permission Errors
If you see permission errors:
- Verify key has required permissions
- Check if key is read-only when write access needed
- Create new key with appropriate permissions
Key Exposed
If your key is exposed:
- Immediately revoke the key in Mailchimp
- Create a new API key
- Update your
.envfile - Restart Claude Desktop
- Review access logs in Mailchimp
Best Practices Summary
- Use read-only keys for exploration
- Store keys securely (
.envfile, encrypted disk) - Rotate keys periodically (every 90 days)
- Use separate keys for different accounts
- Restart Claude Desktop after changing keys
- Never commit keys to version control
- Revoke compromised keys immediately
Need Help?
Related Articles:
Get Tips on Using Claude with Mailchimp
Join our newsletter for tips, tutorials, and updates on AI-powered email marketing.
Related Articles
Advanced Workflows with Mailchimp MCP
🎨 Once you've mastered the basics of Mailchimp MCP, it's time to explore advanced workflows that c...
Read →Success Stories: Real Results with Mailchimp MCP
🌟 Real marketers and businesses are using Mailchimp MCP to transform their email marketing. Here a...
Read →Advanced Analytics Techniques
📊 Go beyond basic metrics to reveal hidden insights and drive strategic decisions. Learn cohort an...
Read →