Skip to content

API Keys

API keys authenticate server-to-server requests to the Synapse API. Each key is scoped to a specific set of operations and tied to a single workspace.


Key Format

psk_live_a1b2c3d4e5f67890abcdef1234567890
│ │ │
│ │ └── 32 random hex characters
│ └─────── environment: live or test
└─────────── prefix: identifies Synapse Customer Communications Platform keys
ComponentValuesDescription
PrefixpskSynapse Customer Communications Platform key identifier (prefix stored key)
EnvironmentliveReal email delivery via Resend
testSandbox mode -- emails logged but not sent
Random32 hex charsCryptographically random, unique per key
Note

The key prefix (psk_live_a1b2 -- first 12 characters) is stored in plaintext for fast lookup. The full key is bcrypt-hashed. Synapse never stores your key in plaintext after creation.


Scopes

Each API key has exactly one scope that determines which endpoints it can access:

ScopeEndpointsUse Case
browserPOST /v1/events, POST /v1/events/batchClient-side Browser SDK event tracking. Safe to embed in frontend code.
dataPOST /v1/events, POST /v1/send, POST /v1/contactsBackend services sending events and transactional emails
reportingGET /v1/analytics/*, GET /v1/analytics/exportDashboard integrations, BI tools, automated reports
managementGET/POST/PUT/DELETE /v1/flows, /v1/templates, /v1/segmentsCI/CD pipelines, infrastructure-as-code
fullAll endpointsDevelopment and testing only
Tip

Browser SDK users: Always use a browser-scoped key in client-side code. Browser keys can only track events -- they cannot send emails, read contacts, or access any admin endpoints. If someone extracts the key from your page source, the blast radius is limited to writing events.

Warning

Avoid using full-scoped keys in production. If a data-scoped key is compromised, the attacker can send events but cannot read your templates, modify flows, or access analytics.


Creating Keys

API keys are created in the Synapse dashboard under Settings > API Keys, or via the management API:

bash
curl -X POST https://synapse-api.pyrx.tech/v1/workspace/api-keys \
-H "Authorization: Bearer <jwt_token>" \
-H "Content-Type: application/json" \
-d '{
"name": "Production Event Ingestion",
"scope": "data",
"environment": "live"
}'

Response

json
{
"key": "psk_live_a1b2c3d4e5f67890abcdef1234567890",
"api_key": {
"id": "9f2e4a6b-1c3d-4e5f-a6b7-c8d9e0f1a2b3",
"name": "Production Event Ingestion",
"key_prefix": "psk_live_a1b2",
"scope": "data",
"environment": "live",
"is_active": true,
"last_used_at": null,
"last_used_ip": null,
"expires_at": null,
"created_at": "2026-04-07T10:30:00Z",
"revoked_at": null
}
}
Warning

The key field is returned only in the creation response. Copy and store it immediately. You will not be able to retrieve it again.


Key Lifecycle

Revoking a Key

Revoked keys are immediately rejected. Any in-flight requests using the key will fail with 401.

bash
curl -X DELETE https://synapse-api.pyrx.tech/v1/workspace/api-keys/9f2e4a6b-1c3d-4e5f-a6b7-c8d9e0f1a2b3 \
-H "Authorization: Bearer <jwt_token>"

Key Expiration

You can optionally set an expiration date when creating a key:

json
{
"name": "Temporary CI Key",
"scope": "management",
"environment": "test",
"expires_at": "2026-05-01T00:00:00Z"
}

Expired keys are automatically rejected. They remain visible in the dashboard for audit purposes.


Rotation Best Practices

  1. Create the new key first -- Generate a replacement key with the same scope and environment.
  2. Deploy the new key -- Update your application configuration to use the new key. For zero-downtime rotation, your application should accept both keys during the transition window.
  3. Verify the new key works -- Send a test event and confirm a 202 response.
  4. Revoke the old key -- Once all services are updated, revoke the previous key.
Tip

Set a calendar reminder to rotate keys every 90 days. Use key names that include the rotation date (e.g., "Production Data Key - Q2 2026") so you can easily identify stale keys.


Environment-Specific Keys

EnvironmentBehaviorDomain
liveEmails are rendered and delivered via ResendEvents processed normally
testEmails are rendered and logged but not sentSafe for development and staging

Use test keys in your development and staging environments. The full event pipeline executes (flow matching, template rendering, email log creation) so you can verify behavior without sending real emails.


Plan Limits

Each plan has a maximum number of API keys:

PlanMax API Keys
Free3
Starter10
Growth25
EnterpriseUnlimited

Attempting to create a key beyond your plan limit returns a 403:

json
{
"detail": "API key limit reached for your plan. Upgrade to create more keys.",
"code": "plan_limit_reached"
}