Stream tokens
API keys must never reach a browser. For browser and agent-desktop access to the realtime stream, your server mints a stream token: short-lived, read-only, and scoped.
ts
const { token, expires_at } = await vi.streamTokens.create({
call_id: "call_123", // optional: restrict to one call
scopes: ["transcript", "assist"], // default ["events", "transcript"]
ttl_sec: 900, // default 3600, max 86400
});python
t = client.stream_tokens.create(call_id="call_123", scopes=["transcript", "assist"], ttl_sec=900)bash
curl -X POST https://api.kolwire.com/v1/stream-tokens \
-H "Authorization: Bearer $KOLWIRE_API_KEY" -H "Content-Type: application/json" \
-d '{"call_id":"call_123","scopes":["transcript","assist"],"ttl_sec":900}'Claims
A token is a signed, opaque string. Its claims:
| Claim | Meaning |
|---|---|
ws | Workspace id. |
call | Optional: only events of this call are delivered. |
scopes | What the holder may receive. |
exp | Expiry (Unix seconds). Connections are refused after it. |
Scopes
| Scope | Grants |
|---|---|
events | Call lifecycle, messaging, queue and agent status events. |
transcript | call.transcript.partial / call.transcript.final. |
assist | call.assist.suggestion. |
audio | Live call audio (listen-in). |
Guidelines
- Authorize your own user before minting (e.g. "is this rep assigned to this call?").
- Scope to a
call_idwhenever the UI is about one call. - Keep TTLs short and give the client a function that fetches a fresh token — the SDK
StreamClientcalls it on every reconnect.