Overview
When you enable S3 storage, Evolution API automatically uploads all media files to your configured S3 bucket instead of storing them locally. This provides:- Scalable, distributed storage for media files
- Reduced server disk usage
- Better performance for multi-instance deployments
- Compatibility with S3-compatible services (MinIO, DigitalOcean Spaces, etc.)
Configuration
Amazon S3 Setup
Create an S3 bucket
Log in to your AWS Console and create a new S3 bucket in your preferred region. Note the bucket name and region for configuration.
Create IAM credentials
Create an IAM user with programmatic access and attach a policy with the following permissions:Save the Access Key ID and Secret Access Key.
Environment Variables
Required Variables
Enable or disable S3 storage integration.Default:
falseThe name of your S3 bucket where media files will be stored.
Your AWS Access Key ID with permissions to write to the S3 bucket.
Your AWS Secret Access Key corresponding to the Access Key ID.
Optional Variables
The S3 endpoint URL. For Amazon S3, use the regional endpoint or
s3.amazonaws.com.Default: s3.domain.comExamples:- Global:
s3.amazonaws.com - Regional:
s3.us-west-2.amazonaws.com - EU:
s3.eu-west-3.amazonaws.com
The AWS region where your S3 bucket is located.Default:
eu-west-3The port to use for S3 connections. Use 443 for HTTPS or 80 for HTTP.Default:
443Enable SSL/TLS for secure connections to S3.Default:
trueRegional Endpoints
Amazon S3 provides regional endpoints for better performance. Use the endpoint closest to your Evolution API deployment:S3-Compatible Services
Evolution API works with any S3-compatible storage service:DigitalOcean Spaces
Cloudflare R2
Wasabi
Backblaze B2
Complete Configuration Example
Here’s a complete working configuration for Amazon S3:.env
Bucket Configuration
Public Access Settings
Your S3 bucket should have:- Block all public access: Enabled
- Bucket versioning: Optional (recommended for backup)
- Server-side encryption: Recommended
CORS Configuration
If you’re accessing media files from a web application, configure CORS on your S3 bucket:Lifecycle Rules
Consider setting up lifecycle rules to manage storage costs:Troubleshooting
Connection timeout errors
Connection timeout errors
If you’re experiencing connection timeouts:
- Verify your
S3_ENDPOINTis correct for your region - Check that your firewall allows outbound HTTPS traffic on port 443
- Ensure your Access Key and Secret Key are valid
- Try using the regional endpoint instead of the global endpoint
Access denied errors
Access denied errors
If you receive access denied errors:
- Verify your IAM user has the correct permissions (PutObject, GetObject, DeleteObject, ListBucket)
- Check that the bucket name in your configuration matches the actual bucket name
- Ensure the bucket policy doesn’t deny access from your server’s IP
- Verify the Access Key and Secret Key are correct and active
Files not uploading
Files not uploading
If files aren’t being uploaded to S3:
- Check that
S3_ENABLED=truein your environment variables - Verify all required variables are set (BUCKET, ACCESS_KEY, SECRET_KEY)
- Check the Evolution API logs for error messages
- Test your credentials using the AWS CLI:
aws s3 ls s3://your-bucket-name
SSL certificate errors
SSL certificate errors
If you encounter SSL certificate errors:
- Ensure
S3_USE_SSL=trueis set - Verify your system has up-to-date CA certificates
- For self-signed certificates, you may need to disable SSL verification (not recommended for production)
Security Best Practices
Follow these security practices when configuring S3 storage:
- Use IAM users with minimal permissions - Only grant necessary S3 permissions
- Enable server-side encryption - Use SSE-S3 or SSE-KMS for data at rest
- Rotate access keys regularly - Change your S3 credentials every 90 days
- Use bucket policies - Restrict access to specific IP ranges or VPCs
- Enable access logging - Track all requests to your S3 bucket
- Never commit credentials - Keep your
.envfile out of version control
Next Steps
MinIO Setup
Learn how to set up self-hosted S3-compatible storage with MinIO
Database Configuration
Configure your database to store instance and message metadata