many-hamburger-5823
09/01/2025, 8:14 AMtall-airline-16756
09/01/2025, 8:14 AMtall-airline-16756
09/01/2025, 8:15 AMremoveParticipant method available in the LiveKit server SDKs. This will disconnect the participant right away, but just a heads up—it doesn’t revoke their access token, so they could come back if given a new token.
Here are some examples for different SDKs to help you out:
• *Node.js SDK:*`const roomService = new RoomServiceClient(LIVEKIT_URL, API_KEY, API_SECRET);
await roomService.removeParticipant(roomName, identity);`
• *Python SDK:*`await room_service.remove_participant(
remove=RoomParticipantIdentity(
room=room_name,
identity=identity,
)
)`
• *Kotlin SDK:*`roomServiceClient.removeParticipant(roomName, identity)`
• *Go SDK:*`_, err := roomClient.RemoveParticipant(context.Background(), &livekit.RoomParticipantIdentity{
Room: roomName,
Identity: identity,
})`
You can also do this quickly using the LiveKit CLI:
lk room participants remove --room=ROOM_NAME --identity=IDENTITY
To make sure the participant can’t rejoin, just keep their access token’s TTL short or avoid giving them a new token altogether.
Sources: Managing participants | LiveKit Docs | packages/livekit-server-sdk/src/RoomServiceClient.ts | livekit-api/livekit/api/room_service.py | src/main/kotlin/io/livekit/server/RoomServiceClient.kt | cmd/lk/room.gomany-hamburger-5823
09/01/2025, 8:16 AMtall-airline-16756
09/01/2025, 8:17 AMfrom livekit_server_sdk import RoomServiceClient, RoomParticipantIdentity
# Initialize the RoomServiceClient
room_service = RoomServiceClient(LIVEKIT_URL, API_KEY, API_SECRET)
# Remove the participant
await room_service.remove_participant(
remove=RoomParticipantIdentity(
room=room_name,
identity=participant_identity,
)
)
Just a heads-up: the Python SDK doesn’t let you add a custom reason for removal directly. But no worries! You can send a custom message to the participant before removing them by using the send_data method. Here’s how you could do it:
from livekit_server_sdk import SendDataRequest, DataPacket
# Send a custom message to the participant
await room_service.send_data(
SendDataRequest(
room=room_name,
data=b"You have been removed for violating community guidelines.",
kind=DataPacket.Kind.RELIABLE,
destination_identities=[participant_identity],
topic="removal_reason"
)
)
# Then remove the participant
await room_service.remove_participant(
remove=RoomParticipantIdentity(
room=room_name,
identity=participant_identity,
)
)
This way, the participant gets a clear, custom message before they’re removed. If you want to chat more about this or need any other help, just let me know—I’m here for you!
Sources: livekit-protocol/livekit/protocol/room.pyi | Connecting to LiveKit | LiveKit Docs | agent/game_host.py | Managing participants | LiveKit Docs