End a session
Last updated Oct 19, 2026 Prerequisites
Ensure your participant's preset has the Kick Participants (kick_participant) host permission enabled.
To end the current session for all participants, remove all participants using kickAll(). This stops any ongoing recording for that session and sets the session status to ENDED.
Ending a session is different from leaving a meeting. Leaving disconnects only the current participant. The session remains active if other participants are still present.
Steps
WebMobile
ReactWeb ComponentsAngular
- Check that the local participant has permission to remove participants.
```ts const canEndSession = meeting.self.permissions.kickParticipant === true;
if (!canEndSession) { // Disable the "End meeting/session" control in your UI. // You can also show a message to explain why the action is not available. } ```
```ts const canEndSession = meeting.self.permissions.kickParticipant === true;
if (!canEndSession) { // Disable the "End meeting/session" control in your UI. // You can also show a message to explain why the action is not available. } ```
```ts const canEndSession = meeting.self.permissions.kickParticipant === true;
if (!canEndSession) { // Disable the "End meeting/session" control in your UI. // You can also show a message to explain why the action is not available. } ```
```kotlin val canEndSession = meeting.localUser.permissions.host.canKickParticipant
if (!canEndSession) { // Disable the "End meeting/session" control in your UI. // You can also show a message to explain why the action is not available. } ```
```swift let canEndSession = meeting.localUser.permissions.host.canKickParticipant
if !canEndSession { // Disable the "End meeting/session" control in your UI. // You can also show a message to explain why the action is not available. } ```
```javascript const canEndSession = meeting.self.permissions.kickParticipant === true;
if (!canEndSession) { // Disable the "End meeting/session" control in your UI. // You can also show a message to explain why the action is not available. } ```
- End the session by removing all participants.
If the participant does not have the required permission, kickAll() throws a ClientError with error code 1201.
ts
try {
await meeting.participants.kickAll();
} catch (err) {
if (err?.code === 1201) {
// The participant does not have permission to end the session.
// Update your UI to indicate that the action is not allowed.
return;
}
throw err;
}
If the participant does not have the required permission, kickAll() throws a ClientError with error code 1201.
ts
try {
await meeting.participants.kickAll();
} catch (err) {
if (err?.code === 1201) {
// The participant does not have permission to end the session.
// Update your UI to indicate that the action is not allowed.
return;
}
throw err;
}
If the participant does not have the required permission, kickAll() throws a ClientError with error code 1201.
ts
try {
await meeting.participants.kickAll();
} catch (err) {
if (err?.code === 1201) {
// The participant does not have permission to end the session.
// Update your UI to indicate that the action is not allowed.
return;
}
throw err;
}
If the participant does not have the required permission, kickAll() returns a HostError.
```kotlin val error: HostError? = meeting.participants.kickAll()
if (error != null) { when (error) { is HostError.KickPermissionDenied -> { // The participant does not have permission to end the session. // Update your UI to indicate that the action is not allowed. } } } else { // Successfully initiated session end } ```
If the participant does not have the required permission, kickAll() returns a HostError.
```swift let error: HostError? = meeting.participants.kickAll()
if let error = error { switch error { case .kickPermissionDenied: // The participant does not have permission to end the session. // Update your UI to indicate that the action is not allowed. break default: break } } else { // Successfully initiated session end } ```
If the participant does not have the required permission, kickAll() throws a ClientError with error code 1201.
javascript
try {
await meeting.participants.kickAll();
} catch (err) {
if (err?.code === 1201) {
// The participant does not have permission to end the session.
// Update your UI to indicate that the action is not allowed.
return;
}
throw err;
}
- Listen for the session end event.
When the session ends, all participants leave the session. The SDK emits a roomLeft event with state set to ended.
ts
meeting.self.on("roomLeft", ({ state }) => {
if (state === "ended") {
// Update your UI to show that the meeting session has ended.
}
});
When the session ends, all participants leave the session. The SDK emits a roomLeft event with state set to ended.
ts
meeting.self.on("roomLeft", ({ state }) => {
if (state === "ended") {
// Update your UI to show that the meeting session has ended.
}
});
When the session ends, all participants leave the session. The SDK emits a roomLeft event with state set to ended.
ts
meeting.self.on("roomLeft", ({ state }) => {
if (state === "ended") {
// Update your UI to show that the meeting session has ended.
}
});
When the session ends, all participants leave the session. You can subscribe to the event listeners to handle the session end.
kotlin
meeting.addMeetingRoomEventListener(object : RtkMeetingRoomEventListener {
override fun onMeetingEnded() {
// Update your UI to show that the meeting session has ended.
}
})
When the session ends, all participants leave the session. You can subscribe to the event listeners to handle the session end.
```swift // Implement the delegate method extension MeetingViewModel: RtkMeetingRoomEventListener { func onMeetingEnded() { // Update your UI to show that the meeting session has ended. } }
meeting.addMeetingRoomEventListener(meetingRoomEventListener: self) ```
When the session ends, all participants leave the session. The SDK emits a roomLeft event with state set to ended.
javascript
meeting.self.on("roomLeft", ({ state }) => {
if (state === "ended") {
// Update your UI to show that the meeting session has ended.
}
});
You can also end a session from your backend by removing all participants using the Kick all participants API.
End a session from your backend
Remove all participants with the API
Use the Kick all participants API method to remove all participants from an active session for a meeting.
<details>
<summary>
Required API token permissions
</summary>
At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:
- <code>Realtime Admin</code>
- <code>Realtime</code>
</details>
Kick all participantsbash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/realtime/kit/$APP_ID/meetings/$MEETING_ID/active-session/kick-all" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
Listen for session end events with webhooks
Register a webhook that subscribes to meeting.ended. RealtimeKit sends this event when the session ends. You can use it to trigger backend workflows, such as sending a notification, generating a report, or updating session records in your database.
<details>
<summary>
Required API token permissions
</summary>
At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:
- <code>Realtime Admin</code>
- <code>Realtime</code>
</details>
Add a webhookbash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/realtime/kit/$APP_ID/webhooks" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"name": "Session ended webhook",
"url": "<YOUR_WEBHOOK_URL>",
"events": [
"meeting.ended"
]
}'
Disable a meeting
Ending a session does not disable the meeting. Participants can join the meeting again and start a new session. To prevent participants from joining again and starting a new session, set the meeting status to INACTIVE using the Update a meeting API. If the meeting has an active session, RealtimeKit also removes all participants from it.
<details>
<summary>
Required API token permissions
</summary>
At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:
- <code>Realtime Admin</code>
- <code>Realtime</code>
</details>
Update a meetingbash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/realtime/kit/$APP_ID/meetings/$MEETING_ID" \
--request PATCH \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"status": "INACTIVE"
}'
Next steps
- Review how presets control permissions in Preset.
- Review the possible values of the local participant room state in Local Participant.
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/realtime/realtimekit/humans/core/end-a-session/#page","headline":"End a session","description":"End a RealtimeKit session for all participants and stop active recordings.","url":"https://developers.cloudflare.com/realtime/realtimekit/humans/core/end-a-session/","inLanguage":"en","image":"https://developers.cloudflare.com/realtime/realtimekit/humans/core/end-a-session/og.png?v=893bca79b6b5d26c","dateModified":"2026-10-19","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: RealtimeKit error codes for identifying and troubleshooting SDK and API issues. title: Error Codes image: https://developers.cloudflare.com/realtime/realtimekit/humans/core/error-codes/og.png?v=d8136809c35e209d
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/realtime/llms.txt
Use this file to discover all available pages before exploring further.
Docs