Authentication
Workspace API keys, the built-in OAuth 2.1 server for MCP clients, and how credentials carry capabilities and agent bindings.
Agent Memory accepts two kinds of bearer credentials on the data plane (/v1) and the MCP endpoints:
| Credential | Who uses it | Scope |
|---|---|---|
Workspace API key (amk_…) | Servers, SDKs, CI jobs, header-based MCP clients | Exactly one workspace (optionally one application) |
| OAuth access token | MCP clients that sign in (Claude Desktop, Claude Code, VS Code), people using their own account | The workspaces the signed-in user has grants on |
Both are sent the same way:
Authorization: Bearer <credential>Requests without a valid credential get 401. A valid credential without the required capability gets 403; a workspace it doesn't hold gets 404.
API keys
Creating a key
In the web console, open API Keys → Create API Key and choose:
- the project (workspace) and, optionally, an application — an application-scoped key always targets that application plus the workspace-wide pool, and requests cannot override it;
- the capabilities (below);
- the agents the key may act as — the first is the key's default agent;
- whether the key may act for users (name end users with
userId); - an optional expiry.
The key is shown once. Only its SHA-256 hash and a short display prefix (amk_ plus 8 characters) are stored, so a database leak never yields usable keys. Programmatic minting is available through the provisioning API, and self-hosted operators can mint the first key from the command line with --bootstrap-key (see Deployment).
Capabilities
| Capability | OAuth scope equivalent | Default |
|---|---|---|
read | memory:read | on |
write | memory:write | on |
feedback | memory:feedback | on |
curate | memory:curate | on |
delete | memory:delete | off |
share | memory:share | off |
promote | memory:promote | off |
Each endpoint's required capability is listed in the API reference. Grant the minimum: a recall-only service needs only read.
Agent binding
Every key is bound to the agent IDs chosen at creation. Requests that omit agentId act as the default agent; naming an unbound agent is refused with 403 policy_denied. A key created with no agent IDs acts only as itself. See Identity and visibility.
Revocation and expiry
Revoking a key (console, or DELETE /api/control/keys/{keyId}) takes effect on the next request on every API replica — key lookups are cached in a shared cache that revocation invalidates. Expired keys stop authenticating automatically.
OAuth for MCP clients
When a deployment enables its built-in OAuth 2.1 authorization server, MCP clients can connect with nothing but a URL:
- The client calls the MCP endpoint without a token and receives
401with aWWW-Authenticateheader pointing at the protected-resource metadata (/.well-known/oauth-protected-resource, RFC 9728). - The metadata names the authorization server; the client discovers it (
/.well-known/oauth-authorization-serveror/.well-known/openid-configuration) and registers itself dynamically (/connect/register). - A browser window opens, the user signs in with their Agent Memory account, and the client receives tokens through the authorization-code flow (
/connect/authorize,/connect/token).
| Detail | Value |
|---|---|
| Flows | Authorization code, refresh token |
| Scopes | openid, email, profile, offline_access, memory |
| Access token lifetime | 60 minutes (default) |
| Refresh token lifetime | 14 days, rolling — each refresh issues a new refresh token and invalidates the old one |
| Revocation | /connect/revocation (RFC 7009) |
Signing in never creates an account: a person without an Agent Memory account is told to finish sign-up in the console first. The token resolves to the person's console account and the workspaces they have grants on. Self-hosted operators configure the server with the OAuth:* keys — see Configuration.
External identity providers
A deployment can instead validate tokens from an external OpenID Connect provider (Auth:Authority). Users and service principals from that provider are mapped to provisioned Agent Memory principals and their workspace grants; a token from an unknown principal is refused. In that mode the MCP metadata advertises the memory:* scopes listed above.
Console sign-in
The web console (/app/) supports sign-in with Google, Microsoft (OpenID Connect) and one-time email codes, depending on what the deployment configures. Organizations can require MFA-verified sign-ins for console access with the tenant setting security.requireMfa. Console sessions are separate from API credentials: agents always use keys or OAuth tokens.
Choosing a credential
| Situation | Use |
|---|---|
| A backend service or batch job | An API key bound to that service's agent ID, with only the capabilities it needs. |
| A backend serving many end users | An API key with act for users, passing userId per request. |
| A developer's MCP client | OAuth sign-in if the deployment supports it, otherwise a personal API key. |
| Several apps sharing one workspace | One application-scoped key per app. |
| Agents that must never see each other's memory | Separate workspaces (and keys), or private visibility. |
Provisioning
Create tenants and workspaces, manage workspace grants and mint or revoke API keys programmatically through the control-plane API.
Multi-tenancy
How tenants are isolated — in the request path, in the database and in optional dedicated databases — and how tenant lifecycle and quotas affect API calls.