TeamDay Docs

Service Tokens

Current Teamday service-token guidance for API automation.

Use service tokens for server-side API automation:

Authorization: Bearer <teamday-service-token>

Create, list, and revoke service tokens from Teamday's security settings. Signed-in owners can also use:

MethodPathPurpose
GET/api/service-tokensList service tokens visible to the signed-in user
POST/api/service-tokensCreate a service token
POST/api/service-tokens/{id}/revokeRevoke a service token

Best practices:

  • Use one token per integration.
  • Store the token in a secret manager.
  • Rotate by creating a replacement, deploying it, then revoking the old token.
  • Never put tokens in prompts, mission descriptions, URLs, or logs.

Restricting a token to one agent

A token may be narrowed at creation so that a leak cannot do more than talk to the agents you named. All three fields are optional, and a token created without them behaves exactly as tokens always have.

POST /api/service-tokens
Content-Type: application/json

{
  "name": "kairon-ua-demo-app",
  "scopes": ["chats:read", "chats:write"],
  "agent_ids": ["01K..."],
  "allowed_cwds": ["/ws/product/projects/kairon-ua-demo-agent"],
  "expires_at": "2027-01-01T00:00:00Z"
}
FieldEffect
agent_idsThe token may only open chats with these agents. Every id must be an agent in your organization; unknown or cross-org ids are refused at creation.
allowed_cwdsA chat may only be created with a cwd inside one of these paths. .. segments are refused.
expires_atISO-8601 or unix seconds. Past it, the token is refused exactly like a revoked one.

What agent_ids actually restricts

Setting agent_ids limits the token to holding a conversation, and nothing else:

AllowedRefused
POST /api/chats with an allowed agentAny other agent_id → 403
POST /api/chats/{id}/messages (both execution_mode values)attachments on a message → 403
GET /api/chats/{id}/messagesA chat this token did not create → 404
GET /api/chats/{id}/eventsFork, delete, restore file changes, rename, re-group, steer → 403
GET /api/chats — only this token's own chatsMinting, rotating or widening tokens → 403
GET /api/agents — needs agents:readJobs, files, missions, secrets, terminals, MCP → 403

Three consequences worth knowing:

  • Chats are keyed to the token that opened them. A chat someone started in the web app, or that a different token created, answers 404 rather than 403, so chat ids cannot be discovered by probing.
  • Scopes are constrained. An agent-restricted token may hold only chats:read, chats:write and agents:read. "*" and tokens:write are refused because they would let the token mint an unrestricted replacement; mcp is refused because an MCP tool call carries no agent the API can check.
  • A rotation inherits the restriction. POST /api/service-tokens/{id}/rotate carries agent_ids, allowed_cwds and expires_at to the replacement.

Where these chats appear

A chat opened by a service token is recorded against that token. It stays out of the issuing person's default chat list — app traffic is not someone's conversation history — and is still reachable deliberately:

QueryShows
GET /api/chatsChats the person started (the default)
GET /api/chats?created_by=tokenChats opened by service tokens
GET /api/chats?created_by=anyBoth

A restricted token always sees only its own chats, whatever it passes.

Limits

allowed_cwds is enforced lexically by the API: the path is normalised, .. is refused, and containment is boundary-aware (/ws/product does not admit /ws/product-x). A symlink inside an allowed directory that points outside it is not resolved, because that requires the filesystem holding the path, which is the runner's rather than the API's. Treat allowed_cwds as containment against path traversal, not against a workspace that already contains an escaping symlink.

An expired or revoked token also closes a live SSE stream, on that stream's next heartbeat (within ~15s) rather than instantly.

On this page