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 application or workload. | $MEMORYSYNC_PROJECT_ID |
X-End-User-ID | Scopes memory to the represented user. | user-123 |
Content-Type | Declares JSON request bodies. | application/json |
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["MEMORYSYNC_PROJECT_ID"],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 | Confirm X-Project-ID identifies a project available to the key. |
| Missing or unexpected memory | Confirm the same X-End-User-ID and project are used for add and query. |
Was this page helpful?