<@U07FRRZH2GN> ```ctx.room.local_participant.``` h...
# ask-ai
d
@icy-policeman-64898
Copy code
ctx.room.local_participant.
how to remove participant from a room
t
Thanks for reaching out, Eugene. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To remove a participant from a room in LiveKit, you can use the
removeParticipant
method from the RoomServiceClient. This method forcibly disconnects the participant from the room. Here are examples for different programming languages: JavaScript/Node.js:
Copy code
await roomClient.removeParticipant(roomName, identity);
Python:
Copy code
await room_client.remove_participant(RoomParticipantIdentity(
    room=room_name,
    identity=identity
))
Go:
Copy code
res, err := roomClient.RemoveParticipant(context.Background(), &livekit.RoomParticipantIdentity{
    Room:     roomName,
    Identity: identity,
})
Note that removing a participant will disconnect them from the room and emit a Disconnected event for that participant. However, this action doesn’t invalidate the participant’s token, so they can still re-join the room unless you take additional measures such as: • Generating access tokens with a short TTL (Time-To-Live) • Not providing a new token to the same participant via your application’s backend Sources: RoomServiceClient | LiveKit JS Server SDK - v2.9.7 | Managing participants | LiveKit Docs | livekit.api.room_service API documentation