Agent Participant: WebSocket Events, Presets, Billing, and Reconnect
How server-side agent participants join live meetings over WebSocket, subscribe to events, stay billed safely, and recover from disconnects.
This page summarizes Cloudflare RealtimeKit documentation on Agent Participant: a server-side meeting participant your backend controls over a WebSocket—useful when you need live transcripts, attendance signals, or broadcast data without a browser or client SDK.
Agent Participant adds a server-side agent to a RealtimeKit meeting. Any backend that can open a WebSocket — a Cloudflare Worker, a Durable Object, or your own server — can connect to it. No client SDK or browser is required.
— Cloudflare, Agent Participant
Agent Participant: what it is and when to use it
Section titled “Agent Participant: what it is and when to use it”An agent is a meeting participant whose preset defines how it joins and whose WebSocket subscriptions define which event categories it receives. Today it is largely receive-only: it can listen to transcripts, participant presence, and broadcasts; sending chat, broadcasts, or media from the agent is planned.
| Approach | Best for |
|---|---|
Hidden agent (hidden_participant: true) |
Compliance monitoring, call-quality review, live analytics without showing a bot in the UI |
Visible agent (hidden_participant: false) |
A named note-taker (for example “Notes bot”) that appears in the participant list |
| Human + client SDK | Full A/V, chat, polls, stage controls, plugins |
For a full comparison after join, see the Capability matrix.
A human participant joins a meeting with the RealtimeKit SDKs. An agent joins with the Agent WebSocket. The table compares what each can do once it is in the meeting.
— Cloudflare, Capability matrix
Agent vs human capabilities (today)
Section titled “Agent vs human capabilities (today)”| Capability | Human | Agent |
|---|---|---|
| Receive live transcripts | Yes | Yes |
| Receive participant joins and leaves | Yes | Yes |
| Receive broadcasts | Yes | Yes |
| Send broadcasts | Yes | No (planned) |
| Send or receive audio, video, screen share | Yes | No (planned) |
| Send or receive chat and polls | Yes | No (planned) |
| Meeting controls (stage, kick, recording) | Yes | No |
Agents can only receive meeting events today. Sending is planned, and those capabilities are marked as planned in the capability table.
— Cloudflare, Capability matrix
To act on a meeting from the server now (for example kicking participants), call the RealtimeKit REST API from your Worker rather than waiting for agent send APIs. See Build an agent.
Build an agent: preset, participant token, and WebSocket
Section titled “Build an agent: preset, participant token, and WebSocket”An agent is added by configuring a preset, creating the agent as a participant (with that preset), then upgrading a WebSocket with the agent’s participant token and chosen subscriptions.
- Create or update a preset (hidden or visible). Patterns are described in Build an agent.
- Create the agent participant with the create-participant API and your preset (see Build an agent and Agent Participant).
- From a Worker, Durable Object, or your server, open the Agent WebSocket with the token and
realtimekit.v1subprotocol. - Handle
session.started, then subscribed events as JSON untilsession.endedor you close the connection.
An agent is a meeting participant that your backend controls over a WebSocket. To add one, configure a preset, add the agent as a participant, and connect to the Websocket endpoint with the agent’s participant token.
— Cloudflare, Build an agent
Requirements from Build an agent: a RealtimeKit app and meeting, a Cloudflare API token with RealtimeKit access, and—for transcript.received—real-time transcription enabled on the presets of speakers you want transcribed (permissions.transcription_enabled: true). Without that, the agent gets no transcript.received events.
Connect to the Agent WebSocket URL
Section titled “Connect to the Agent WebSocket URL”Open a WebSocket to the agent endpoint with the participant token and subprotocol:
GET wss://api.realtime.cloudflare.com/agent-ws/v1?subscriptions=transcript,participant,broadcastAuthorization: Bearer <PARTICIPANT_TOKEN>Sec-WebSocket-Protocol: realtimekit.v1The token selects the meeting. HTTP 101 means the connection is ready. The agent then joins the meeting and sends session.started.
— Cloudflare, Build an agent
subscriptions query parameter: which events you get
Section titled “subscriptions query parameter: which events you get”| Parameter | Role |
|---|---|
subscriptions |
Optional comma-separated categories: transcript, participant, broadcast |
connection_id |
Optional; resumes a prior connection (see Reconnect) |
Session-level events are always sent regardless of subscriptions. Unknown categories reject the connection with 400 INVALID_QUERY. See Events and Build an agent.
| Category | Events | Needs |
|---|---|---|
| (always) | session.started, session.ended, participant.kick_all |
— |
transcript |
transcript.received |
Real-time transcription on speakers’ presets |
participant |
participant.join, participant.leave |
Nothing extra |
broadcast |
broadcast.received |
Your app sends broadcasts |
Subscribe only to what you use. Fewer events means less queueing during reconnects.
— Cloudflare, Build an agent
Hidden agent vs visible agent: what people see
Section titled “Hidden agent vs visible agent: what people see”Both patterns use the same connection steps and receive the same subscribed events; only the preset changes.
| Pattern | Preset | Others see it |
|---|---|---|
| Hidden | hidden_participant: true |
No |
| Visible | hidden_participant: false |
Yes (name you set when adding the participant) |
Hidden agent: filtered from UI, not secret from clients
Section titled “Hidden agent: filtered from UI, not secret from clients”Hidden agents are not shown in participant list or video grid; RealtimeKit SDKs filter them out. Join/leave events still fire—clients may receive them but SDKs choose not to display them.
Because people cannot see a hidden agent, your backend must disconnect it when work is done (billing and session lifetime apply).
Visible agent: tile without A/V
Section titled “Visible agent: tile without A/V”A visible agent appears by the display name you pass when adding the participant. It occupies a tile in the video grid even without audio or video; in a custom Core SDK grid you can filter by participant.presetName.
Anything said before the agent joins is not captured. Add the agent before the meeting starts to capture the whole session.
— Cloudflare, Build an agent
Agent Participant events: delivery rules and payloads
Section titled “Agent Participant events: delivery rules and payloads”Agent Participant sends meeting activity as JSON messages. Every message uses the same envelope; dispatch on name and ignore unknown fields.
Every message has the same envelope:
{ "category": "message", "name": "<event name>", "data": {} }— Cloudflare, Events
How agent events are delivered
Section titled “How agent events are delivered”| Rule | Meaning |
|---|---|
| Live only | No history; connecting mid-session only gets later events |
| Ordered per source | Transcripts and participant events are ordered within their stream, not across streams |
| At-least-once on restart | Duplicates possible if the server restarts mid-send |
| Reconnect queue | Up to 10,000 unsent events per connection, replayed on resume |
| Gaps | 1013 upstream_lost on loss; a second session.started marks the gap |
Excluded from the stream: participants already present when the agent joined (no initial roster), the agent’s own join/leave, and hidden/recorder/livestreamer connections. Details: Events.
transcript.received for live note-taking and monitors
Section titled “transcript.received for live note-taking and monitors”Requires the transcript subscription and transcription enabled on speakers’ presets. Partials (is_final: false) may be followed by a final for the same speech; there is no segment ID—replace the latest partial per speaker and persist finals.
Partials (is_final: false) can be followed by a final for the same speech. There is no segment ID. Replace the latest partial per speaker, and store only finals.
— Cloudflare, Events
For client-side live captions (human attendees), presets and meeting.ai are documented in Transcription and RTKAi. Post-meeting Whisper transcripts (transcribe_on_end) are a separate path via webhooks or REST (Transcription, Webhooks).
session.ended and why the agent keeps the meeting alive
Section titled “session.ended and why the agent keeps the meeting alive”While the agent stays connected, it counts as a participant, so the session does not end on its own when humans leave.
A connected agent counts as a participant, so the session does not end on its own while the agent is connected.
— Cloudflare, Events
After session.ended, the server closes with 1000 session_ended; open a new connection for the next session.
Billing and ending the session when the agent stays connected
Section titled “Billing and ending the session when the agent stays connected”The agent is billed as a participant for the entire time it is connected.
The agent is billed as a participant for as long as it is connected. A connected agent keeps the session active even after everyone else leaves, so your backend must remove it.
— Cloudflare, Agent Participant
RealtimeKit charges participant minutes from join until leave (Build an agent — Billing and ending the session, FAQ — Billing). Active minutes include time without producing or consuming media.
| Method | Effect |
|---|---|
Close WebSocket with code 1000 |
Agent leaves immediately; session ends when no other participants remain |
| Kick all participants API | Removes everyone including the agent; agent gets participant.kick_all and session.ended |
Use kick-all when the scheduled end time passes and you must stop billing and any in-progress recording tied to the session (Build an agent).
Reconnect and connection_id: grace period and close codes
Section titled “Reconnect and connection_id: grace period and close codes”Store connection.id from a connection.get request and pass it as connection_id on resume. It identifies the WebSocket connection, not the participant or session.
| Close code | Typical reason | Action |
|---|---|---|
1000 |
session_ended |
New connection for the next session |
1013 |
queue_overflow |
New connection without connection_id |
1013 |
upstream_lost / upstream_unavailable |
Resume with connection_id (backoff if unavailable) |
4403 |
upstream_rejected |
Fix token or participant |
4409 |
replaced |
Do not reconnect |
Closing with 1000 makes the agent leave the meeting immediately. Any other close starts a 5-second grace period. The agent stays joined and queues events.
— Cloudflare, Build an agent
Events sent while the agent was out of the meeting are lost; a second session.started marks the gap. On resume, unsent queued events deliver first, in order. If you pass subscriptions on resume, it replaces the stored list; queued events are not re-filtered.
Send connection.ping every 20 seconds; reconnect if no result within 10 seconds (Build an agent — Reconnect).
Common mistakes with Agent Participant
Section titled “Common mistakes with Agent Participant”- Leaving the WebSocket open after humans leave — continues participant-minute billing and keeps the session active (Agent Participant, Events).
- Subscribing to
transcriptwithout preset transcription — notranscript.receivedevents (Build an agent). - Joining a visible note-taker late — speech before join is not captured (Build an agent).
- Assuming hidden agents are invisible on the wire — join/leave events still propagate; do not rely on hidden for client-side secrecy (Build an agent).
- Subscribing to everything “just in case” — increases queue pressure on reconnect (Build an agent).
- Expecting the agent to send chat or media today — receive-only; use REST for control actions (Capability matrix, Build an agent — Send events).
How to check this on your site
Section titled “How to check this on your site”- Confirm the agent preset has the intended
hidden_participantvalue and, for transcripts,permissions.transcription_enabled: trueon speaker presets (Build an agent, Transcription). - Open the Agent WebSocket with your participant token and
Sec-WebSocket-Protocol: realtimekit.v1; verify HTTP 101 and an incomingsession.started(Build an agent). - Send
connection.getover the socket and confirmsubscriptionsmatch your query string (Build an agent — Requests). - End a test meeting, close the agent with WebSocket code
1000, and confirmmeeting.endedon your webhook if configured (End a session, Webhooks). - You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about.