REST API Reference
Complete reference for the MeMesh Cloud REST API. The V2 primary surface is the agent workspace: dispatch targets, orchestrator runs, local execution control, approvals, runtime health, and compatibility retirement. All endpoints require authentication via the x-api-key header.
https://api.memesh.ai/v1Authentication Header
x-api-key: mk_your_api_key_hereAll requests must include a valid API key. Create keys from Setup > Agent Access Keys.
Agent Workspace
Tenant-scoped dispatch targets and target-level governance truth.
/agents/dispatch-targetsList tenant-scoped local and remote dispatch targets with dispatch eligibility, runtime policy, controls, and compatibility/runtime summaries.
Query: search?, targetKind? (LOCAL_AGENT|REMOTE_A2A), state?, limit?, offset?
/agents/dispatch-targets/:idGet one dispatch target detail including remote control capability or local runtime summary.
/agents/dispatch-targets/:id/governanceGovernance drill-down with runtime policy, review state, provider-incident handoff, recent runs, recent audit, impacted work, and timeline.
/agents/dispatch-targets/:id/holdPlace a manual hold on a dispatch target. Requires expectedRuntimeUpdatedAt CAS token.
Body: { reason, releaseAfter?, expectedRuntimeUpdatedAt }
/agents/dispatch-targets/:id/releaseRelease a manual hold and recompute effective policy in one CAS-protected mutation.
Body: { note?, expectedRuntimeUpdatedAt }
/agents/dispatch-targets/:id/review/acknowledgeAcknowledge the active governance review for the current policy epoch.
Body: { note?, expectedRuntimeUpdatedAt }
/agents/dispatch-targets/:id/incident/handoffRecord provider-incident handoff for the active incident epoch.
Body: { externalIncidentId, owner, note?, expectedRuntimeUpdatedAt }
Memory
Store and search memories with semantic search via pgvector embeddings.
/memory/writeWrite a new memory with optional metadata. Memories are automatically embedded for semantic search.
Body: { content, space?, summary?, tags?, sensitivity?, source? }
/memory/searchSemantic search across stored memories using a natural language query.
Query: query (required), spaces?, limit?
/memory/searchSemantic search with structured request body. Recommended for complex queries.
Body: { query, spaces?, limit? }
/memory/countGet total memory count for the authenticated user.
/memory/batchBatch write up to 100 memories. Supports transactional (all-or-nothing) or partial success modes.
Body: { memories[], transactional? }
/memory/batch/searchExecute up to 50 search queries in parallel with optional cross-query deduplication.
Body: { queries[], deduplicate? }
/memory/spacesList all memory spaces for the authenticated user.
/memory/queryNatural language query with hybrid filtering. Supports temporal, tags, and semantic search.
Body: { query, limit?, offset?, similarityThreshold? }
/memory/context-windowSelect memories for LLM context window within a token budget.
Body: { query, tokenBudget }
/memory/stream/exportStream memory export using Server-Sent Events. No timeout for large exports.
Query: spaces?
Orchestrator Runtime
Persisted runs, control truth, reconcile, retry-cancel, and runtime health.
/orchestrator/runsList recent runs with target kind, control truth, approval links, and operator guidance.
/orchestrator/runs/:idGet run detail including events, approvals, remote control state, and suggested operator action.
/orchestrator/runs/:id/controlReturn control capability truth, block reasons, and operator guidance for one run.
/orchestrator/runs/:id/reconcileForce-poll remote state and reconcile late terminal truth.
/orchestrator/runs/:id/retry-cancelRetry a remote cancel after timeout or transient failure.
/orchestrator/runs/:id/resolve-remoteGuarded operator resolution for remote runs after recovery exhaustion.
/orchestrator/runtime-healthOperator health summary for local compatibility, remote escalation, target governance, and attention backlog.
Local Agent Execution
Claim-token based local execution queue with leases, heartbeat, recovery, and cancel acknowledgement.
/agents/executionsList pending local executions available to the current agent.
/agents/executions/:id/claimClaim a local execution using a caller-supplied claimToken.
Body: { claimToken, workerId? }
/agents/executions/:id/heartbeatExtend the active lease and optionally report progress.
Body: { claimToken, progressMessage? }
/agents/executions/:id/completeComplete the claimed execution.
Body: { claimToken, result?, idempotencyKey? }
/agents/executions/:id/ack-cancelAcknowledge cancel after the runtime requests local interruption.
Body: { claimToken, note? }
Team
Team member management, invitations, and role-based access control.
/team/membersList all team members for the current tenant.
/team/members/inviteInvite a new team member by email. Requires OWNER or ADMIN role.
Body: { email, role? }
/team/members/:userId/roleChange a team member's role.
Body: { role }
/team/members/:userIdRemove a member from the team.
Audit
Query audit logs for security monitoring and compliance.
/audit/logsQuery audit logs with optional filters by action, resource, date range, and limit.
Query: action?, resource?, startDate?, endDate?, limit? (default: 100)
Billing & Usage
Subscription plans, usage statistics, and quota management.
/billing/planGet the current user's subscription plan (free, pro, or enterprise).
/usage/summaryGet complete usage statistics including memory, API keys, agents, seats, and rate limits.
API Keys
Create, list, and revoke API keys for programmatic access.
/keysCreate a new API key. The key value is only shown once in the response.
Body: { name }
/keysList all API keys for the current user (values are masked).
/keys/:idPermanently revoke an API key.
Device Authorization
OAuth 2.0 Device Authorization flow (RFC 8628) for CLI and MCP clients.
/auth/deviceInitiate device authorization flow. Returns device_code, user_code, and verification_uri. Public endpoint.
Body: { client_id, scope? }
/auth/device/tokenPoll for token after user authorizes the device. Public endpoint.
Body: { grant_type: "urn:ietf:params:oauth:grant-type:device_code", device_code }
Example Requests
curl "https://api.memesh.ai/v1/agents/dispatch-targets?targetKind=REMOTE_A2A&limit=10" \
-H "x-api-key: mk_your_api_key"curl -X POST https://api.memesh.ai/v1/orchestrator/runs/run_123/reconcile \
-H "x-api-key: mk_your_api_key" \
-H "Content-Type: application/json"curl -X POST https://api.memesh.ai/v1/agents/dispatch-targets/{targetId}/hold \
-H "x-api-key: mk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"reason": "provider maintenance",
"releaseAfter": "2026-03-22T09:00:00.000Z",
"expectedRuntimeUpdatedAt": "2026-03-20T09:00:00.000Z"
}'HTTP Status Codes
| Code | Description |
|---|---|
| 200 | Success |
| 201 | Created (resource created) |
| 400 | Bad Request (validation error, invalid Agent Card) |
| 401 | Unauthorized (invalid or missing API key) |
| 403 | Forbidden (self-review blocked, insufficient permissions) |
| 404 | Not Found (agent or resource does not exist) |
| 409 | Conflict (stale policy epoch, stale runtime snapshot, duplicate claim) |
| 429 | Too Many Requests (rate limit exceeded) |