API Key Management
Best practices for the full lifecycle of Synapse API keys: creation, storage, rotation, revocation, and environment isolation.
Key Lifecycle
Creation
Create keys in the dashboard (Settings > API Keys) or via the API. Each key requires:
- Name: A descriptive label (e.g., "Production Event Ingestion Q2 2026")
- Scope:
data,reporting,management, orfull - Environment:
liveortest
The full API key is returned only in the creation response. Copy it immediately and store it in a secrets manager. Synapse cryptographically hashes the key and cannot retrieve the plaintext.
Secure Storage
Do
- Store keys in environment variables or a secrets manager (AWS Secrets Manager, HashiCorp Vault, Doppler)
- Use different keys per environment (development, staging, production)
- Use different keys per service or team
Do Not
- Commit keys to version control (even in
.envfiles if the repo is not private) - Log API keys in application logs
- Share keys via email, Slack, or other unencrypted channels
- Hardcode keys in application source code
Scope Best Practices
Assign the minimum scope needed for each use case:
| Service | Recommended Scope |
|---|---|
| Backend event ingestion | data |
| Transactional email sender | data |
| Analytics dashboard / BI tool | reporting |
| CI/CD pipeline (template deployment) | management |
| Internal admin scripts | full (with expiration) |
| Development / testing | full + test environment |
A compromised data-scoped key can send events but cannot read templates, modify flows, or export analytics. Scope limiting reduces blast radius.
Environment-Specific Keys
| Environment | Key Environment | Behavior |
|---|---|---|
| Development | test | Events processed, emails logged but not sent |
| Staging | test | Full pipeline execution without email delivery |
| Production | live | Full pipeline execution with real email delivery |
Always use test keys in non-production environments to prevent accidental email sends during development.
Rotation
Rotate API keys every 90 days or immediately if a key may be compromised.
Zero-Downtime Rotation
- Create a new key with the same scope and environment
- Update application configuration to use the new key
- Deploy the configuration change
- Verify the new key works (send a test event, confirm
202response) - Revoke the old key
Naming Convention
Include the rotation date or quarter in the key name:
- "Production Data Key - Q2 2026"
- "Staging Management Key - 2026-04"
This makes it easy to identify stale keys that need rotation.
Monitoring
Track key usage in the dashboard under Settings > API Keys:
| Metric | Description |
|---|---|
last_used_at | Timestamp of the most recent request |
last_used_ip | IP address of the most recent request |
Keys that have not been used in 90+ days may be orphaned. Review and revoke unused keys to reduce your security surface.
Revocation
Revoking a key is immediate and irreversible. Any request using a revoked key receives 401 Unauthorized.
Revoked keys remain visible in the dashboard (marked as revoked) for audit purposes.
Emergency: Compromised Key
If you suspect an API key has been compromised:
- Revoke the key immediately -- Do not wait for a replacement to be deployed
- Create a new key with the same scope
- Deploy the new key to all affected services
- Review email logs for any unauthorized sends during the compromise window
- Review audit logs to understand what actions the compromised key performed