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
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_tokenfor protected methods. - May use project scope where supported.
- Does not send
X-End-User-ID.
Create a protected client
control_plane.py
import osfrom memorysync import ControlPlaneClientwith 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
| Area | Methods |
|---|---|
| API keys | bulk_revoke_api_keys, test_api_key |
| Authentication | login |
| Billing | get_current_plan |
| Team | list_team_members, suspend_team_member, remove_team_member |
| Sessions | list_sessions, revoke_session |
| Audit | list_audit_events |
| Integrations | list_integrations |
| Organizations | create_organization, list_organizations, list_organization_members, get_organization_settings |
| Projects | list_projects |
| Webhooks | create_webhook, list_webhooks, update_webhook, delete_webhook, test_webhook, replay_webhook_deliveries, list_webhook_deliveries |
Login does not configure the client
login.py
import osfrom memorysync import ControlPlaneClientwith 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 osfrom memorysync import AsyncControlPlaneClientasync 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
Control-plane API pages
Open account, organization, audit, project, billing, and webhook operations.
Python Types & Errors
Handle typed dictionary results and failures.
API Authentication
Compare memory API keys and bearer authentication.
Production Patterns
Authorize, log, and reconcile administrative calls.