Overview
Synap uses API keys for all SDK authentication. Set your key and your instance id as environment variables and you are done.SYNAP_INSTANCE_ID is optional, and the dashboard gives you both together so you can paste them in one go.
Getting your API key
- Log in to the Synap Dashboard
- Navigate to your instance
- Click API Keys in the instance detail page
- Click Generate API Key, give it a label, and copy the key
synap_ and look like this:
Using the API key
Option 1: Environment variable (recommended)
SetSYNAP_API_KEY and SYNAP_INSTANCE_ID:
Option 2: Constructor parameter
Pass the key directly:Priority order
Wheninitialize() is called, the SDK resolves credentials in this order:
- The constructor parameter (
api_key=in Python,apiKeyin JavaScript) SYNAP_API_KEYenvironment variable
initialize() raises an AuthenticationError.
The instance id resolves the same way (instance_id= / instanceId, then SYNAP_INSTANCE_ID), but it is optional: if neither is set, initialize() resolves it from your API key. Setting it changes nothing about which instance you reach, since the key already determines that.
Multiple keys per instance
You can generate multiple API keys for the same instance. Each key has a label and can be revoked independently. Common patterns:
Revoke any key without affecting the others.
These patterns each put one key in one process, which is what you want. If a single process uses two keys that belong to the same instance, you get two independent SDKs rather than one shared one, and
initialize() warns you about it. See Two keys, one instance.In JavaScript, credentials resolve identically and the SDK reads
SYNAP_API_KEY from process.env on every runtime that exposes it, Edge and
Workers included. See Where it runs.Security best practices
Never commit API keys to version control
Never commit API keys to version control
Use
.env files (added to .gitignore) or your platform’s secrets manager. GitHub’s secret scanning will flag leaked synap_ keys automatically.Use separate keys per environment
Use separate keys per environment
Generate a different key for development, staging, CI, and production. If one leaks, revoke only that key; the others continue working.
Rotate keys periodically
Rotate keys periodically
Generate a new key, update your environment, verify it works, then revoke the old one. There’s no expiry deadline; rotate on your own schedule.
Serverless and edge deployments
Serverless and edge deployments
API keys work everywhere: Vercel, AWS Lambda, Cloudflare Workers, Docker, Kubernetes. Set
SYNAP_API_KEY in your platform’s environment configuration and you’re done. No file I/O, no extra setup step.