MemorySync
SDKs · Python

Python 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

Python authentication boundary

MemorySyncClient

Memory data plane.

  • Uses api_key.
  • Uses project and end-user scope.
  • Does not accept a bearer access token.

ControlPlaneClient

Administrative control plane.

  • Uses access_token for protected methods.
  • May use project scope where supported.
  • Does not send X-End-User-ID.

Create a protected client

control_plane.py
import os
from memorysync import ControlPlaneClient
with ControlPlaneClient(
"https://api.memorysync.io",
access_token=os.environ["MEMORYSYNC_ACCESS_TOKEN"],
project_id=os.environ.get("MEMORYSYNC_PROJECT_ID"),
) as control:
projects = control.list_projects()
for project in projects:
print(project["id"], project["name"])

All 23 control-plane methods

AreaMethods
API keysbulk_revoke_api_keys, test_api_key
Authenticationlogin
Billingget_current_plan
Teamlist_team_members, suspend_team_member, remove_team_member
Sessionslist_sessions, revoke_session
Auditlist_audit_events
Integrationslist_integrations
Organizationscreate_organization, list_organizations, list_organization_members, get_organization_settings
Projectslist_projects
Webhookscreate_webhook, list_webhooks, update_webhook, delete_webhook, test_webhook, replay_webhook_deliveries, list_webhook_deliveries

Login does not configure the client

login.py
import os
from memorysync import ControlPlaneClient
with ControlPlaneClient("https://api.memorysync.io") as control:
result = control.login(
"developer@example.com",
os.environ["MEMORYSYNC_PASSWORD"],
)
if result.get("mfa_required"):
print("Complete the configured MFA flow")
elif "tokens" in result:
access_token = result["tokens"]["access_token"]
# Store and use tokens only in an approved secure context.

Apply project scope explicitly

project_scope.py
with ControlPlaneClient(
"https://api.memorysync.io",
access_token=os.environ["MEMORYSYNC_ACCESS_TOKEN"],
project_id="project_default",
) as control:
default_hooks = control.list_webhooks()
selected_hooks = control.list_webhooks(project_id="project_selected")

Project-aware methods can use the client default or a non-empty per-call override. Resolve either value from authorized server state.

Create webhooks from trusted input

create_webhook.py
created = control.create_webhook(
"Memory events",
"https://hooks.example.com/memorysync",
["memory.created"],
project_id="project_selected",
)
print(created["id"])
# Treat a returned webhook secret as a secret and do not log it.

Use the async control-plane client

async_control_plane.py
import os
from memorysync import AsyncControlPlaneClient
async with AsyncControlPlaneClient(
"https://api.memorysync.io",
access_token=os.environ["MEMORYSYNC_ACCESS_TOKEN"],
) as control:
sessions = await control.list_sessions()
print(len(sessions["sessions"]))

Operation reference