Back to Blog
Security 7 min read Jan 8, 2025

Securing Your API Keys: A Complete Guide

Best practices for managing API keys and keeping your integration secure.

Why API Key Security Matters

Your API key is the gateway to your CallPayMin account. A compromised key could allow attackers to create calls, access user data, or rack up charges on your account.

Never Expose Your API Key

Never commit API keys to version control, include them in client-side code, or share them in public channels.

Use Environment Variables

Store your API keys in environment variables, not in your codebase:

.env (never commit this file)
CALLPAYMIN_API_KEY=cpm_live_xxxxxxxxxxxxx
.gitignore
.env
.env.local
.env.production

Use Scoped API Keys

Create API keys with only the permissions they need. This limits damage if a key is compromised.

ScopePermissionsUse Case
calls:createCreate new callsBackend call creation
calls:readRead call detailsAnalytics, dashboards
users:manageCreate/update usersUser onboarding
billing:readRead billing dataFinancial reporting
webhooks:manageConfigure webhooksAdmin tools

Create Separate Keys per Environment

Use different API keys for development, staging, and production:

Development

Test key with limited scopes. Safe to experiment with.

Staging

Mirrors production scopes. For pre-release testing.

Production

Full access. Protect with maximum security.

Rotate Keys Regularly

Rotate your API keys periodically (every 90 days recommended) and immediately if you suspect a breach:

  1. Create a new API key in your dashboard
  2. Update your environment variables
  3. Deploy the changes
  4. Verify the new key works
  5. Revoke the old key

Security Checklist

  • Store keys in environment variables
  • Add .env files to .gitignore
  • Use minimal scopes for each key
  • Create separate keys per environment
  • Rotate keys every 90 days
  • Monitor API usage for anomalies
  • Never expose keys in client-side code

Manage Your Keys

Visit the API Keys Dashboard to create, view, and revoke your API keys.