Skip to main content

Overview

Synap uses API keys for all SDK authentication. Set your key and your instance id as environment variables and you are done.
The SDK authenticates every request to Synap Cloud using your API key. SYNAP_INSTANCE_ID is optional, and the dashboard gives you both together so you can paste them in one go.
Set the instance id as an environment variable, not as a constructor argument. SYNAP_INSTANCE_ID records which instance you are on and leaves the SDK keyed on your credential. Passing instance_id= to MaximemSynapSDK(...) is different: it makes the id the identity, so a second key used under it is silently discarded and key rotation stops taking effect. See Singleton Pattern.

Getting your API key

  1. Log in to the Synap Dashboard
  2. Navigate to your instance
  3. Click API Keys in the instance detail page
  4. Click Generate API Key, give it a label, and copy the key
The key is displayed only once. Copy it immediately. If you lose it, revoke it and generate a new one.
API keys start with synap_ and look like this:

Using the API key

Set SYNAP_API_KEY and SYNAP_INSTANCE_ID:
The SDK reads these automatically:
This is the recommended approach for all environments: local development, CI/CD, Docker, Kubernetes, Vercel, AWS Lambda.

Option 2: Constructor parameter

Pass the key directly:

Priority order

When initialize() is called, the SDK resolves credentials in this order:
  1. The constructor parameter (api_key= in Python, apiKey in JavaScript)
  2. SYNAP_API_KEY environment variable
The first one that succeeds wins. If neither is available, 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

Use .env files (added to .gitignore) or your platform’s secrets manager. GitHub’s secret scanning will flag leaked synap_ keys automatically.
Generate a different key for development, staging, CI, and production. If one leaks, revoke only that key; the others continue working.
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.
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.

Troubleshooting