API Keys
API keys (tokens) control access to the MemoryLayer API. Each token carries a name, a principal type, workspace patterns, scopes, and an optional expiration. Tokens are stored and validated by Aether; the /v1/tokens endpoints manage them through the server’s Aether connection, and the Aether auth proxy checks them on every request.
All token endpoints require admin access (admin:read to list and get, admin:write to create, revoke, and delete). If the server is not connected to Aether, they return 503. The examples use $MEMORYLAYER_URL for your deployment’s API endpoint.
Token Fields
| Field | Type | Default | Description |
|---|---|---|---|
name | string | — | Human-readable token name (required) |
principal_type | string | User | Principal type for the token |
workspace_patterns | string[] | ["*"] | Workspace access patterns with wildcard support |
scopes | string[] | ["*"] | Permission scopes |
expires_in_days | integer | — | Days until expiration (omit for no expiry) |
Create a Token
curl -X POST "$MEMORYLAYER_URL/v1/tokens" \ -H "Authorization: Bearer $ML_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "CI Pipeline Token", "workspace_patterns": ["ci-*", "staging-*"], "scopes": ["*"], "expires_in_days": 90 }'Response (201 Created):
{ "id": "42", "name": "CI Pipeline Token", "principal_type": "User", "workspace_patterns": ["ci-*", "staging-*"], "scopes": ["*"], "created_at": "2026-01-15T10:30:00+00:00", "expires_at": "2026-04-15T10:30:00+00:00", "revoked": false, "token": "<plaintext token>"}List Tokens
curl "$MEMORYLAYER_URL/v1/tokens" \ -H "Authorization: Bearer $ML_API_KEY"Revoked tokens are excluded by default. To include them:
curl "$MEMORYLAYER_URL/v1/tokens?include_revoked=true" \ -H "Authorization: Bearer $ML_API_KEY"Response:
{ "tokens": [ { "id": "42", "name": "CI Pipeline Token", "principal_type": "User", "workspace_patterns": ["ci-*", "staging-*"], "scopes": ["*"], "created_at": "2026-01-15T10:30:00+00:00", "expires_at": "2026-04-15T10:30:00+00:00", "revoked": false } ]}Get Token Details
curl "$MEMORYLAYER_URL/v1/tokens/42" \ -H "Authorization: Bearer $ML_API_KEY"Returns 404 if the token does not exist.
Revoke a Token
Revoking a token invalidates it. The token record is preserved and visible in listings with include_revoked=true and revoked: true.
curl -X POST "$MEMORYLAYER_URL/v1/tokens/42/revoke" \ -H "Authorization: Bearer $ML_API_KEY"Returns 204 No Content on success.
Delete a Token
Permanently removes the token record.
curl -X DELETE "$MEMORYLAYER_URL/v1/tokens/42" \ -H "Authorization: Bearer $ML_API_KEY"Returns 204 No Content on success.
Workspace Pattern Wildcards
Workspace patterns use glob-style matching to control which workspaces a token can access:
| Pattern | Matches |
|---|---|
* | All workspaces |
production | Only the production workspace |
project-* | project-alpha, project-beta, etc. |
team-a-* | team-a-dev, team-a-staging, team-a-prod |
A token with ["project-*", "shared"] can access any workspace starting with project- plus the shared workspace.
Token Expiration
- Omit
expires_in_days(or set it tonull) to create a token that never expires. - Set
expires_in_daysto a positive integer to create a time-limited token. - Expired tokens are rejected at authentication time.
Errors
| Code | Meaning |
|---|---|
502 | Aether rejected the request or returned an error |
503 | The server has no Aether connection |
504 | The Aether request timed out |
Security Best Practices
- Scope tokens narrowly. Prefer specific workspace patterns over
*for production tokens. - Set expiration dates. Use
expires_in_daysfor CI/CD tokens and short-lived integrations. - Revoke before deleting. Revoke a compromised token immediately, then delete it after confirming nothing depends on it.
- Rotate regularly. Create a new token, update consuming services, then revoke the old one.
- Name tokens descriptively. Use names like
ci-deploy-stagingormonitoring-readonlyso the purpose is clear when auditing. - Store securely. Keep tokens in a secrets manager or environment variables, never in source code.