Authentication Overview
Evolution API uses API key authentication to secure all endpoints. There are two types of authentication:- Global API Key - Full access to all instances and administrative operations
- Instance Token - Restricted access to a specific instance only
apikey header with either a global key or instance-specific token.
API keys are passed via the
apikey HTTP header (not Authorization). This allows you to use standard authentication schemes like JWT for your own application layer.Global API Key
The global API key grants full administrative access to your Evolution API installation.Setting the Global Key
Configure in your.env file:
Generate a Secure Key
Global Key Capabilities
With the global API key, you can:- Create new instances
- Delete any instance
- Fetch information about all instances
- Access any instance’s endpoints
- Modify system-wide configurations
Instance Tokens
Each instance has its own unique authentication token, providing scoped access to that instance only.How Instance Tokens Work
When you create an instance, Evolution API generates a unique token:Custom Instance Tokens
You can specify a custom token during instance creation:Custom tokens must be unique across all instances. The API will reject duplicate tokens.
src/api/services/auth.service.ts:7):
Using Instance Tokens
Instance tokens restrict API access to only that instance:Authentication Flow
Here’s how Evolution API validates requests:1
Extract API Key
The API extracts the
apikey header from your request:2
Check Global Key
First, check if the key matches the global API key:
3
Check Instance Token
If not a global key, verify it’s a valid instance token:
4
Reject Invalid Keys
If neither match, reject the request:
Security Best Practices
Use HTTPS in Production
Use HTTPS in Production
Always use HTTPS to encrypt API keys in transit:Configure SSL in your
.env:Rotate Keys Regularly
Rotate Keys Regularly
Implement a key rotation policy:
- Generate a new global API key
- Update your
.envfile - Restart Evolution API
- Update all client applications
Store Keys Securely
Store Keys Securely
Never hardcode API keys in your application:Use environment variables, secret managers, or encrypted configuration files.
Restrict Instance Tokens
Restrict Instance Tokens
For customer-facing applications, always use instance tokens instead of the global key:
Monitor Authentication Failures
Monitor Authentication Failures
Track failed authentication attempts:
Implement IP Whitelisting
Implement IP Whitelisting
Restrict API access by IP address at the network level:Or use a firewall/VPC to limit access to your Evolution API server.
Authentication in Different Languages
Expose Instances Configuration
Control which instances are visible in fetch requests:true- All instances are returned in fetch requestsfalse- Instances are hidden, only explicitly requested instances are returned
Common Authentication Errors
403 Forbidden - Wrong Instance Token
403 Forbidden - Wrong Instance Token
400 Bad Request - Duplicate Token
400 Bad Request - Duplicate Token
Next Steps
Instances
Learn how to create and manage instances
Webhooks
Configure webhooks for real-time event notifications
Multi-Tenant
Build secure multi-tenant applications
API Reference
Explore all available API endpoints