SDKs · Node.js
Node.js Control Plane
Use ControlPlaneClient for trusted account, organization, billing, audit, session, project, integration, API-key, and webhook workflows. Protected methods use a bearer access token—not a memory API key.
Choose the correct credential
MemorySyncClient
Memory data plane.
- Uses
apiKey. - Uses project and end-user scope.
- Does not accept a bearer access token.
ControlPlaneClient
Administrative control plane.
- Uses
accessTokenfor protected methods. - May use project scope where supported.
- Does not send an end-user ID.
Create a protected client
control-plane.ts
import { ControlPlaneClient } from "memorysync-sdk";const control = new ControlPlaneClient({baseUrl: "https://api.memorysync.io",accessToken: process.env.MEMORYSYNC_ACCESS_TOKEN!,projectId: process.env.MEMORYSYNC_PROJECT_ID,});const projects = await control.listProjects();for (const project of projects) {console.log(project.id, project.name);}
All 23 control-plane methods
| Area | Methods |
|---|---|
| API keys | bulkRevokeApiKeys, testApiKey |
| Authentication | login |
| Billing | getCurrentPlan |
| Team | listTeamMembers, suspendTeamMember, removeTeamMember |
| Sessions | listSessions, revokeSession |
| Audit | listAuditEvents |
| Integrations | listIntegrations |
| Organizations | createOrganization, listOrganizations, listOrganizationMembers, getOrganizationSettings |
| Projects | listProjects |
| Webhooks | createWebhook, listWebhooks, updateWebhook, deleteWebhook, testWebhook, replayWebhookDeliveries, listWebhookDeliveries |
Login does not configure the client
login.ts
import { ControlPlaneClient } from "memorysync-sdk";const loginClient = new ControlPlaneClient({baseUrl: "https://api.memorysync.io",});const result = await loginClient.login({email: "developer@example.com",password: process.env.MEMORYSYNC_PASSWORD!,});if (result.mfaRequired) {console.log("Complete the configured MFA flow");} else {const accessToken = result.tokens.accessToken;// Store and use tokens only in an approved secure context.}
Apply project scope explicitly
project-scope.ts
const control = new ControlPlaneClient({baseUrl: "https://api.memorysync.io",accessToken: process.env.MEMORYSYNC_ACCESS_TOKEN!,projectId: "project_default",});const defaultHooks = await control.listWebhooks();const selectedHooks = await control.listWebhooks({projectId: "project_selected",});
Every control-plane method accepts a final request-options object with an optional project override. Resolve the client default and override from authorized server state.
Create webhooks from trusted input
create-webhook.ts
const created = await control.createWebhook({name: "Memory events",url: "https://hooks.example.com/memorysync",events: ["memory.created"],projectId: "project_selected",},{ projectId: "project_selected" },);console.log(created.id);// Treat created.secret as a secret and do not log it.
Use exact audit query names
audit-events.ts
const result = await control.listAuditEvents({limit: 25,cursor: 0,sortDirection: "desc",includeStats: false,});for (const event of result.events) {console.log(event.eventId, event.action, event.success);}