TokST Durable context for people and AI agents

REST API Reference

Stable compatibility surface. TokST maintains existing REST routes and contracts in V0.9.0. Cloud MCP is the public Agent interface for durable knowledge; this reference documents the compatible REST knowledge surface.

API scope

TokST publishes this REST API as a stable compatibility surface for durable knowledge. New integrations should use Cloud MCP for memory, context, knowledge bases, workspace governance, evidence files, and account status.

Connected Runtime APIs support the TokST CLI, device bridges, automatic sessions, Agent communication, and directed tasks. They remain private implementation interfaces and are not a public integration contract.

Authentication

Send your TokST API key in the Authorization header:

curl https://api.tokst.com/v1/status \
  -H "Authorization: Bearer tk_live_xxxxxxxxxxxxxxxx"

Keep API keys in a secret manager or environment variable. REST requests use the Authorization header.

OAuth for Remote MCP

Remote MCP clients use OAuth 2.1 authorization code flow with PKCE. Connect the client to https://api.tokst.com/mcp; it discovers /.well-known/oauth-protected-resource/mcp and /.well-known/oauth-authorization-server, opens TokST for account and workspace approval, then stores refreshable bearer credentials. REST automations continue to use an API key.

Endpoint Inventory

Health and Account

MethodPathAuthDescription
GET/healthNoService health check
GET/v1/statusYesPlan, monthly usage, storage, personal workspace and Atlas quotas, Team workspace quota, and totals

Memories

MethodPathDescription
POST/v1/memoriesCreate a memory and generate its embedding
GET/v1/memoriesList active memories
GET/v1/memories/contextBuild a grouped context snapshot
POST/v1/memories/searchKeyword-first search with scoped semantic fallback
GET/v1/memories/:idGet one memory, including attachment metadata
PATCH/v1/memories/:idUpdate content, title, type, or tags
POST/v1/memories/:id/verifyVerify a memory with evidence, confidence, or expiry
POST/v1/memories/:id/supersedeMark a memory as replaced by a newer record
POST/v1/memories/:id/archiveArchive a memory
POST/v1/memories/:id/appendAppend content and regenerate the embedding
POST/v1/memories/:id/restoreRestore an archived memory

Memory lifecycle

Memory changes are reversible through archive and restore. The public compatibility API does not expose permanent memory deletion. A user may permanently clear an archived memory only from the Dashboard archive view after manual confirmation.

Atlases

MethodPathDescription
GET/v1/atlasesList accessible atlases
GET/v1/atlases/:idGet one atlas
POST/v1/atlasesCreate an atlas
PATCH/v1/atlases/:idRename an atlas or replace routing keywords
POST/v1/atlases/:id/archiveArchive or restore an atlas

Workspaces

MethodPathDescription
GET/v1/workspacesList accessible workspaces
GET/v1/workspaces/:idGet one workspace
POST/v1/workspacesCreate a workspace
POST/v1/workspaces/:id/archiveArchive or restore a workspace
GET/v1/workspaces/:id/membersList workspace members and roles
GET/v1/workspaces/:id/invitationsList sent invitations
POST/v1/workspaces/:id/invitationsCreate one or more invitations; emails, role, and expiresInDays
PATCH/v1/workspaces/:id/members/:userIdChange a member between admin and member; body requires confirm: true
DELETE/v1/workspaces/:id/members/:userId?confirm=trueRemove a member
POST/v1/workspaces/:id/leaveLeave a workspace; body requires confirm: true
POST/v1/workspaces/:id/owner-transferTransfer ownership to an existing member; body requires userId and confirm: true
GET/v1/workspace-invitationsList the caller's pending invitations
POST/v1/workspace-invitations/:id/respondAccept or decline an invitation; body requires accept and confirm: true
DELETE/v1/workspace-invitations/:idRevoke a pending invitation; send ?confirm=true

Memory Requests

Create

curl -X POST https://api.tokst.com/v1/memories \
  -H "Authorization: Bearer $TOKST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Production deploys require approval on Fridays.",
    "type": "decision",
    "title": "Release policy",
    "tags": ["deploy", "policy"],
    "atlasId": "00000000-0000-0000-0000-000000000000"
  }'

content is required. type defaults to note. Supported types are fact, decision, preference, task, architecture, and note. When workspaceId is supplied it must match the selected atlas.

List and Context

# type accepts one value or a comma-separated list; limit is 1-100
curl "https://api.tokst.com/v1/memories?atlas_id=$ATLAS_ID&type=decision,note&limit=20" \
  -H "Authorization: Bearer $TOKST_API_KEY"

curl "https://api.tokst.com/v1/memories/context?atlas_id=$ATLAS_ID&limit=10" \
  -H "Authorization: Bearer $TOKST_API_KEY"

Search

curl -X POST https://api.tokst.com/v1/memories/search \
  -H "Authorization: Bearer $TOKST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"release approval rules","atlas_id":"'$ATLAS_ID'","mode":"auto","limit":10}'

mode accepts auto, keyword, semantic, or hybrid and defaults to auto. The response includes mode plus meta with the requested/resolved mode, cache level, strong-keyword decision, and stage timings.

  • keyword returns ranked title/content keyword matches.
  • semantic returns vector results only.
  • hybrid always fuses both lists with RRF.
  • keyword_fallback records a bounded embedding failure while preserving keyword results.

Update and Append

curl -X PATCH https://api.tokst.com/v1/memories/mem_xxx \
  -H "Authorization: Bearer $TOKST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"content":"Updated policy","type":"decision","tags":[]}'

curl -X POST https://api.tokst.com/v1/memories/mem_xxx/append \
  -H "Authorization: Bearer $TOKST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"content":"Approved by the release manager."}'

Sending an empty tags array clears existing tags. Content updates and appends regenerate the semantic embedding.

Verify and Supersede

curl -X POST https://api.tokst.com/v1/memories/mem_xxx/verify \
  -H "Authorization: Bearer $TOKST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"evidence":"https://example.com/policy","confidence":0.95,"validUntil":"2027-01-01T00:00:00Z"}'

curl -X POST https://api.tokst.com/v1/memories/mem_old/supersede \
  -H "Authorization: Bearer $TOKST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"replacementMemoryId":"mem_new"}'

Verification marks a record as reviewed and stores its supporting metadata. Superseding marks the earlier record as superseded and preserves a link to the replacement.

Atlas and Workspace Requests

curl -X POST https://api.tokst.com/v1/workspaces \
  -H "Authorization: Bearer $TOKST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Platform Team"}'

curl -X POST https://api.tokst.com/v1/atlases \
  -H "Authorization: Bearer $TOKST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Production","workspaceId":"'$WORKSPACE_ID'","keywords":["deploy","release"]}'

Archive Atlases and Workspaces through their archive operations. The Dashboard archived views provide the user-confirmed permanent cleanup path.

Team Membership

# Invite multiple people for seven days.
curl -X POST "https://api.tokst.com/v1/workspaces/$WORKSPACE_ID/invitations" \
  -H "Authorization: Bearer $TOKST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"emails":["[email protected]","[email protected]"],"role":"member","expiresInDays":7}'

# The recipient accepts an invitation from their own inbox.
curl -X POST "https://api.tokst.com/v1/workspace-invitations/$INVITATION_ID/respond" \
  -H "Authorization: Bearer $TOKST_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"accept":true,"confirm":true}'

The database enforces workspace roles for every membership RPC. Owner manages all membership changes and ownership transfer. Admin manages ordinary members. Member can leave and can manage only their own memories.

File Workflow

File transfers use the unified Supabase Edge Function at /functions/v1/tokst. These routes accept the short-lived user JWT returned by POST /auth/exchange, while normal REST routes accept tk_live_... API keys.

MethodEdge pathPurpose
POST/auth/exchangeExchange an API key for a user JWT
POST/storage/upload-urlValidate ownership and quota, create a pending attachment, return a signed PUT URL
POST/storage/confirm-uploadVerify the R2 object exists, record actual size and MIME, activate the attachment
GET/storage/download-urlReturn a 15-minute signed download URL
POST/storage/delete-objectsServer-managed, ownership-checked object cleanup

The CLI, web dashboard, and MCP tools implement this workflow. See File Attachments for complete examples.

Response and Error Model

Successful responses return a typed JSON object documented in the OpenAPI 3.1 contract. Errors use one stable shape:

{
  "error": "quota_exceeded",
  "code": "quota_exceeded",
  "message": "The current monthly quota has been reached. Retry after the reported reset time or upgrade capacity."
}

error remains available for existing clients. code is the canonical machine-readable value. message provides recovery guidance and must not be parsed for program control.

StatusMeaningCommon codes
400Invalid body, query, or resource relationshipinvalid_query, atlas_workspace_mismatch
401Missing or invalid API keymissing_api_key, invalid_key
403Revoked key or forbidden object accessrevoked, forbidden
404Route or accessible resource was not foundnot_found
409Resource state prevents the operationworkspace_not_empty, upload object missing
429Monthly quota or rolling rate limit reachedquota_exceeded, rate_limited
500Server-side failureinternal_error

Resource lookups are scoped to the authenticated owner and workspace memberships. A resource outside that scope resolves as unavailable.

Rate Limit Headers

Authenticated REST responses expose the monthly quota window using standard headers:

HeaderMeaning
RateLimit-LimitTotal operations allowed in the current quota window
RateLimit-RemainingOperations remaining in the current quota window
RateLimit-ResetSeconds until the quota window resets
Retry-AfterSeconds to wait before retrying; returned with HTTP 429

Clients should slow or pause work when RateLimit-Remaining approaches zero. After 429, wait for Retry-After before retrying. TokST currently exposes pull-based REST and MCP interfaces; public outbound webhooks are not available.

Versioning and Deprecation

TokST keeps stable cloud REST routes under /v1. Additive fields, endpoints, and optional request parameters can ship within /v1. A change that removes a field, changes its meaning, or changes authorization behavior receives a new major API path.

TokST announces a planned endpoint or field retirement in this reference and the release history at least 90 days before removal. During the announced period, affected HTTP responses include Deprecation: true and a Sunset date where the route can provide those headers. Clients should treat unknown response fields as forward-compatible and use error codes rather than parsed error text for recovery logic.

MCP Endpoint

The same host serves the complete 32-tool MCP Streamable HTTP surface at https://api.tokst.com/mcp. See the MCP reference.

Connected Runtime

Automatic sessions, Agent communication, task delivery, and task execution use the authenticated TokST Runtime after the CLI connects a device. These private Runtime APIs are maintained for the Dashboard and connected CLI; external integrations use Cloud MCP for durable knowledge.