Skip to content

Authentication & Scopes

Synapse uses two authentication methods that map to different parts of the API. Understanding which method to use -- and which scopes to request -- is essential for secure integration.


Two Auth Methods

MethodUsed forHow it works
API keyData-plane endpoints (events, contacts, sending, analytics)X-WORKSPACE-ID + X-API-KEY headers, or Basic Auth
JWTControl-plane endpoints (members, billing, workspace settings)Authorization: Bearer <token> from dashboard session

Data-plane endpoints are the programmatic API surface -- the endpoints your backend services call to ingest events, send emails, manage content, and read analytics. These accept API key authentication.

Control-plane endpoints manage workspace configuration: team members, billing, workspace deletion, and ownership transfer. These require a dashboard JWT and are not accessible via API key.

Note

Some endpoints accept both methods. For example, contacts and domains endpoints work with either an API key (with appropriate scope) or a JWT. The auth badge on each API page tells you which methods are accepted.


API Key Authentication

Sending Credentials

Option A: Header-based (recommended)

bash
curl -X POST https://synapse-api.pyrx.tech/v1/events \
-H "Content-Type: application/json" \
-H "X-WORKSPACE-ID: ws_k7x9m2p4" \
-H "X-API-KEY: psk_live_a1b2c3d4e5f67890abcdef1234567890" \
-d '{"event_name": "signup", "external_id": "user_123", "attributes": {}}'

Option B: Basic Auth

bash
curl -X POST https://synapse-api.pyrx.tech/v1/events \
-H "Content-Type: application/json" \
-H "Authorization: Basic $(echo -n 'ws_k7x9m2p4:psk_live_a1b2c3d4e5f67890abcdef1234567890' | base64)" \
-d '{"event_name": "signup", "external_id": "user_123", "attributes": {}}'

Option C: Query parameter (browser SDK only)

POST https://synapse-events.pyrx.tech/v1/events?api_key=psk_live_a1b2c3d4e5f67890abcdef1234567890

For browser sendBeacon calls that cannot set custom headers. The workspace is resolved from the key.


Scope Catalog

Each API key has a single scope that grants a set of fine-grained permissions:

data scope

For backend services that send events, upsert contacts, and trigger transactional emails.

PermissionDescription
events:writeIngest events via POST /v1/events
contacts:writeCreate and update contacts
send:writeSend transactional emails via POST /v1/send

reporting scope

For BI tools, dashboards, and automated report pipelines.

PermissionDescription
analytics:readRead analytics and dashboard metrics
flows:readList flows and flow details
logs:readRead email delivery logs
contacts:readRead contact records
templates:readRead email template content

management scope

For CI/CD pipelines and infrastructure-as-code that manage CRM configuration.

PermissionDescription
flows:writeCreate, update, and delete flows
templates:writeCreate, update, and delete templates
templates:readRead email template content
segments:writeCreate, update, and delete segments
contacts:writeCreate and update contacts
contacts:readRead contact records
settings:writeUpdate workspace settings

full scope

Combines all permissions from data, reporting, and management. Use only in development and testing environments.

Warning

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


Scope Presets (Common Configurations)

Use caseRecommended scopeWhy
Event ingestiondataBackend sends events and upserts contacts. No read access needed.
Reporting / BIreportingRead-only access to analytics, logs, and contacts. Cannot modify anything.
Content managementmanagementManages flows, templates, and segments. Does not send events.
Full data planefullDevelopment and testing only. Grants all API key permissions.

JWT Authentication (Dashboard)

JWT tokens are issued by pyrx.auth when a user logs into the Synapse dashboard. They are short-lived (15 minutes) and verified using cached JWKS public keys.

bash
curl https://synapse-api.pyrx.tech/v1/workspace/members \
-H "Authorization: Bearer eyJhbGciOiJFUzI1NiIs..."

JWT authentication provides access to control-plane endpoints that API keys cannot reach:

  • Members API -- invite, update roles, deactivate team members
  • Billing API -- view plan, checkout, manage subscription
  • Workspace management -- transfer ownership, delete workspace

Multi-Workspace Users

If a user belongs to multiple workspaces, include X-WORKSPACE-ID to specify the workspace context:

bash
curl https://synapse-api.pyrx.tech/v1/flows \
-H "Authorization: Bearer eyJhbGciOiJFUzI1NiIs..." \
-H "X-WORKSPACE-ID: ws_k7x9m2p4"

Error Responses

401 -- Authentication Failed

CodeCause
invalid_api_keyAPI key is missing, revoked, expired, or does not match
token_expiredJWT has expired (15-minute TTL)
invalid_tokenJWT signature is invalid or claims are malformed

403 -- Authorization Failed

CodeCause
insufficient_scopeAPI key scope does not include the required permission for this endpoint
control_plane_onlyEndpoint requires JWT authentication (dashboard only) -- API keys are not accepted
insufficient_roleJWT user's role does not have the required permission
json
{
"detail": "API key scope 'data' does not permit: flows:read",
"code": "insufficient_scope"
}
json
{
"detail": "This endpoint requires dashboard authentication. API keys are not accepted.",
"code": "control_plane_only"
}

Endpoint Auth Reference

Endpoint groupAPI keyJWTRequired scope
Events (/v1/events)YesNodata -- events:write
Contacts (/v1/contacts)YesYesdata or management -- contacts:write / contacts:read
Direct Send (/v1/send)YesNodata -- send:write
Flows (/v1/flows)YesYesreporting (read) or management (write)
Templates (/v1/templates)YesYesreporting (read) or management (write)
Segments (/v1/segments)YesYesmanagement -- segments:write
Analytics (/v1/analytics)YesYesreporting -- analytics:read
Email Logs (/v1/email-logs)YesYesreporting -- logs:read
Domains (/v1/workspace/domains)NoYesDashboard auth required
Jobs (/v1/jobs)NoYesDashboard auth required
Webhook Endpoints (/v1/workspace/webhook-endpoints)NoYesDashboard auth -- webhooks:read / webhooks:write
Members (/v1/workspace/members)NoYesDashboard auth -- members:read / members:write
Billing (/v1/workspace/billing)NoYesDashboard auth -- owner only
Workspace (/v1/workspace)NoYesDashboard auth required