Skip to main content

Authentication

The SDK authenticates with an API key generated when you create an Instance in the Synap Dashboard. One key per Instance; rotate or revoke at any time.
Never expose your API key in client-side code, public repositories, or browser requests. API keys should only be used in server-side environments.
See Authentication for a detailed walkthrough of API key generation and the credential lifecycle.

SDK versioning

The SDK and the underlying wire protocol are versioned. Non-breaking additions (new fields, new optional parameters) may be added within a major version without notice. Breaking changes ship in new major versions of the SDK; the upgrade path is documented in the Changelog.

Pagination

List methods on the SDK return paginated results. Pass page and page_size to control the window:
integer
Page number to retrieve. Defaults to 1.
integer
Number of items per page. Defaults to 20. Maximum 100.
Returned objects include both the data and the pagination envelope:

Rate Limiting

Requests are rate-limited per API key. When the limit is exceeded, the SDK raises RateLimitError. Tier limits: The SDK automatically retries with exponential backoff on rate-limit errors. The exception carries the server’s Retry-After:

Correlation IDs

Every SDK call records a correlation ID: a unique identifier propagated through the full request lifecycle, including background jobs like ingestion. Read it from a context response’s metadata, or from any Synap error:
Always include the correlation_id when contacting support. It allows the team to trace the exact request path and identify issues quickly.

Error handling

The SDK raises typed exceptions for different failure classes. Each exception exposes a code (machine-readable), a message (human-readable), and a details object with context:
All SDK exceptions inherit from SynapError and split into two branches: SynapTransientError (the SDK auto-retries) and SynapPermanentError (your code must handle). Common exceptions: For the full hierarchy and per-exception handling guidance, see Error Handling. For wire-level error codes (when interpreting the server’s code field), see Error Codes.

SDK installation

The official Python SDK is the primary customer interface.
A JavaScript/TypeScript SDK is also available for Node.js environments:
The JavaScript client mirrors this namespaced API one to one, and keeps a flat JavaScript-idiomatic surface alongside it. See JavaScript and TypeScript SDK.

Reading these examples in JavaScript or TypeScript

The examples throughout this reference are written in Python. They translate mechanically, because the two SDKs share namespaces, method names and field names exactly. Two differences, and that is all:
  1. Python passes keyword arguments; JavaScript passes one options object.
  2. Python’s MaximemSynapSDK() is JavaScript’s new SynapClient(), and its initialize() / shutdown() are spelled the same.
Field names stay snake_case in JavaScript on the namespaced surface, so a Python example’s argument names can be copied across unchanged. The flat surface (fetchUserContext, searchMemory) is the exception: it returns the normalised camelCase shape. Pick one style per codebase.
The JavaScript SDK is a native Node.js client requiring Node.js 20+. Context and memory operations run on Node, Vercel Edge, Cloudflare Workers and the browser. The optional anticipation stream needs raw TCP and so is Node only. See Installation → JavaScript and TypeScript SDK.
See the Installation guide for full setup instructions for both SDKs.