In Cloudflare RealtimeKit, what does the backend create so a patient can join a video visit, and what does the client SDK receive?
answer
- server objects before any browser code
- a room that never starts or ends
- role chosen per person, not per room
- one token per participant per meeting
basics
~20 sThe backend uses a Cloudflare API token to create a reusable meeting and add each person as a participant with a preset. That returns a participant auth token, the only credential the client SDK receives to join.
solid answer
~40 sRealtimeKit splits the work between your backend and the client SDK. With a Cloudflare API token that holds the Realtime permission, the backend creates a **meeting** (a reusable room with no start or end time) in a RealtimeKit app, then calls Add Participant with a `preset_name` and, optionally, a `custom_participant_id`. The response carries a participant auth token: a JWT scoped to that one participant in that one meeting, which the frontend hands to the SDK as `authToken` (for example `RealtimeKitClient.init({ authToken })`). The preset sets the meeting type and the person's permissions, so the clinician and the patient in one visit can hold different presets. The API token stays on the server; RealtimeKit runs signaling and media routing, and configures TURN for its clients.
code
bash · 5 linescurl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/realtime/kit/$APP_ID/meetings/$MEETING_ID/participants" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{"name": "Patient 4821", "preset_name": "patient", "custom_participant_id": "usr_4821"}'go deeper
Recall the chain: app, meeting, participant with a preset, participant auth token to the SDK. Say clearly which credential lives only on the server.
Explain sessions versus meetings, the token's fixed 100-day life, and why refresh does not revoke while deleting the participant does.
Show how the backend enforces appointment windows and offboarding itself, because RealtimeKit tokens do not encode a schedule.
Weigh what RealtimeKit takes off the team's plate (signaling, TURN, UI, recording) against the per-participant-minute bill and less control over media.
## What RealtimeKit is **RealtimeKit** is the higher-level half of Cloudflare Realtime. It gives web and mobile apps meeting SDKs, a prebuilt **UI Kit** and a lower-level **Core SDK**, while Cloudflare handles signaling, media routing on the Realtime SFU and TURN. The other half, the **Realtime SFU**, exposes raw WebRTC sessions and tracks and leaves signaling, rooms and permissions to you. For a telehealth app that wants group visits quickly, RealtimeKit is the usual starting point, and the first thing to learn is which objects the backend creates before any browser code runs. ## The objects | Object | What it is | Who creates it | | --- | --- | --- | | **App** | A workspace holding meetings, presets and recordings; teams keep one for staging and one for production | Dashboard or API, once | | **Meeting** | A reusable virtual room with a title and feature settings, but no start or end time | Backend, per visit or per care team | | **Session** | The live instance of a meeting: created when the first person joins, marked `ENDED` shortly after the last one leaves | RealtimeKit, automatically | | **Participant** | A user allowed to join one specific meeting | Backend, through Add Participant | | **Preset** | A reusable set of permissions, meeting type (video, audio, webinar) and look, defined at app level | Dashboard or API | A meeting can have only **one active session** at a time, and you are charged per participant only while a session is active, not for an idle meeting. ## The join flow, step by step 1. The backend holds a **Cloudflare API token** with the Realtime permission (Realtime Admin in the token editor). It never ships to the browser. 2. When a visit is booked, the backend creates a meeting with `POST .../accounts/{account_id}/realtime/kit/{app_id}/meetings` and stores the returned meeting `id` beside the appointment. 3. When the patient opens the visit, the backend checks its own rules (is this the patient, is it the right time) and calls Add Participant on that meeting with a `preset_name` such as a patient preset, plus a `custom_participant_id` that maps to an internal user ID. 4. The response returns a participant `id` and a **participant auth token**. The backend gives that token to the frontend. 5. The frontend passes it to the SDK, for example `RealtimeKitClient.init({ authToken })` followed by `meeting.join()`, or to the UI Kit's meeting component. ## What the browser holds - The participant auth token is a **JWT** whose `meetingId` and `participantId` fields tie it to one participant in one meeting; it grants nothing in other meetings. - It is valid for **100 days** from issue, and the lifetime cannot be configured. Scheduling ("only between 14:00 and 14:30") is your backend's job, enforced before you add the participant or hand out a token. - **Refresh Participant Token** issues a new token for the same participant and preset; it does **not** invalidate earlier tokens. - To cut someone off, kick them from any active session first, then **delete the participant**, which revokes every token issued to them for that meeting. - Setting the meeting's status to `INACTIVE` stops anyone joining it, even with a valid token. - The SDKs do not cache tokens in browser or device storage. ## What RealtimeKit does for you - **Signaling and media.** The SDK connects to RealtimeKit, which routes media through the Realtime SFU; you never call the SFU's session and track API yourself. - **TURN.** RealtimeKit configures Cloudflare TURN for its clients, which matters when some clinicians sit behind restrictive hospital networks. - **Roles.** The clinician can join with a host-style preset that can admit people from the waiting room and mute others, while patients get a preset with fewer controls. - **Extras.** Recording, transcription through Workers AI, chat, polls and webhooks are features of the product rather than things you build. ## Mistakes that show up in review - Putting the Cloudflare API token in frontend code so the browser can call Add Participant itself. Anyone who reads the bundle can then create meetings and participants in your account. - Reusing one participant auth token for several people. Each person needs their own participant, both for permissions and for per-participant reporting. - Using an email address or phone number as `custom_participant_id`; the docs ask for a stable internal ID instead. - Expecting a token to expire at the end of the appointment. It lasts 100 days unless you delete the participant.
- A patient's access must end when the visit ends, but the token lasts 100 days; what do you do?Enforce the window in your backend: only add the participant or hand out a token inside the appointment window. At the end, kick participants from the active session, then set the meeting's status to `INACTIVE` or delete the participant. Deleting the participant revokes all of their tokens for that meeting; refreshing a token does not revoke the old one.
- Where do a clinician's extra controls come from if both people join the same meeting?From the preset applied to each participant. Presets are defined at app level and attached when the backend calls Add Participant, so one meeting can hold a host-style preset for the clinician and a more limited one for the patient. The meeting itself carries features such as recording on start, not per-person roles.
- The browser calls the RealtimeKit API directly with the account's API token.
- A meeting has a start time and expires on its own when it ends.
- Refreshing a participant token invalidates the previous one.
- Presets are attached to meetings, so everyone in a meeting shares one role.
- One shared auth token can be handed to every patient in a group visit.
Assumes RealtimeKit as of 2026-10-10, where participant auth tokens have a fixed, non-configurable 100-day lifetime.