Getting Started
Authentication Setup
Use a MemorySync API key from trusted server code. Each memory request also carries project and end-user scope so the service can return the correct data set.
Required request context
| Header | Purpose | Example |
|---|---|---|
X-API-Key | Authenticates your server. | $MEMORYSYNC_API_KEY |
X-Project-ID | Selects the project when the API key is organization-wide. Omit it when the key is already locked to a project. | $MEMORYSYNC_PROJECT_ID |
X-End-User-ID | Scopes memory to the represented user. | user-123 |
Content-Type | Declares JSON request bodies. | application/json |
Where the project ID comes from
- Open the project menu in the dashboard header. Every project shows its ID. The ID is
proj_followed by 16 hexadecimal characters. - Creating an API key while a project is selected locks the key to that project. MemorySync then resolves the project from the key, so Python and Node.js can omit
MEMORYSYNC_PROJECT_ID, and cURL can omitX-Project-ID. - An organization-wide key still requires the header. Copy the ID from the project menu and set
MEMORYSYNC_PROJECT_ID. A header that names a different project than a locked key is rejected.
Authenticated request example
import osfrom memorysync import MemorySyncClientclient = MemorySyncClient(api_key=os.environ["MEMORYSYNC_API_KEY"],base_url="https://api.memorysync.io",project_id=os.environ.get("MEMORYSYNC_PROJECT_ID") or None,end_user_id="user-123",)memory = client.add("The user prefers concise answers and dark mode.",source="chat",metadata={'conversation_id':'conv-42'},)
Handle keys safely
- Load keys from environment variables or a managed secret store.
- Call MemorySync from your backend, never directly from untrusted browser code.
- Use separate credentials for separate environments and workloads.
- Rotate a key if it may have appeared in source control, logs, or client output.
- Return only the data your own application authorizes to its clients.
Choose a stable end-user identifier
Use the same opaque identifier whenever your server acts for the same person. Generate it in your own system and avoid direct personal information such as email addresses. Changing the identifier creates a different memory scope.
Troubleshoot authentication
| Symptom | Check |
|---|---|
| Authentication error | Confirm the environment variable is loaded and the key is active. |
| Project scope error | If the key is organization-wide, set X-Project-ID to the ID from the project menu. If the key is project-locked, omit the header or send that same ID. |
| Missing or unexpected memory | Confirm the same X-End-User-ID and project are used for add and query. |
Was this page helpful?