Skip to main content

API key scopes

API keys are created via the apiKeys.create RPC (cookie-auth only). Each key carries a set of scopes that determine which contract namespaces the bearer can access.

Source

ApiKeyScopeSchema is defined in packages/web-contracts/src/schemas.ts.

Scope table

ScopeGates
sessions:readRead access to sessions.list and sessions.get.
sessions:writeWrite access to sessions.fork, sessions.delete, and sessions.update.
chat:sendAccess to chat.send and chat.abort.
personalities:readRead access to personalities.list, personalities.get, personalities.characterSheet, and personality skills read methods.
memory:readRead access to memory.list and memory.get.
memory:writeWrite access to memory.write. Implies memory:read at the server level.
tools:approveAccess to tools.approve and tools.deny for the tool approval workflow.
events:subscribeAccess to the SSE endpoint (/sse/sessions/:sessionId). Required for EventStream.

ApiKeyMetadata

When you create or list keys, each key returns an ApiKeyMetadata object:

FieldTypeDescription
idstringUnique key identifier.
prefixstringFirst characters of the key (e.g. esk_abc...) for identification without exposing the secret.
namestringHuman-readable label set at creation.
scopesApiKeyScope[]Scopes granted to this key.
allowedOriginsstring[]Origins permitted to use this key (CORS enforcement).
createdAtstringISO-8601 creation timestamp.
lastUsedstring | nullISO-8601 timestamp of last use, or null if never used.
revokedAtstring | nullISO-8601 timestamp of revocation, or null if active.

Creating a key

The apiKeys namespace is restricted to cookie-auth. A bearer token cannot mint new keys.

import { EthosClient } from '@ethosagent/sdk';

// Cookie-auth -- browser context
const client = new EthosClient({ baseUrl: 'http://localhost:2400' });

const { secret, key } = await client.rpc.apiKeys.create({
name: 'my-dashboard',
scopes: ['sessions:read', 'chat:send', 'events:subscribe'],
allowedOrigins: ['https://dashboard.example.com'],
});

// `secret` is the plaintext key -- shown once, never again.
// `key` is the ApiKeyMetadata for the new key.

Minimum viable scope set

A Mission Control that sends messages and renders responses needs at minimum:

  • chat:send -- to start turns
  • events:subscribe -- to receive streamed responses
  • sessions:read -- to list and fetch session history