how do i kill a session via the API?
# ask-ai
w
how do i kill a session via the API?
t
Thanks for reaching out, Alvaro. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking how to kill a session via the API — to end all participant connections in a room, use the DeleteRoom API. 1. To remove a room (disconnects all participants) you need the
roomAdmin
grant and call DeleteRoom with the room name. 2. Examples: • Go:
Copy code
_, err := roomClient.DeleteRoom(context.Background(), &livekit.DeleteRoomRequest{
  Room: "myroom",
})
• Python:
Copy code
from livekit.api import DeleteRoomRequest

await lkapi.room.delete_room(DeleteRoomRequest(
  room="myroom",
))
• Node.js:
Copy code
roomService.deleteRoom('myroom').then(() => {
  console.log('room deleted');
});
• CLI:
Copy code
lk room delete myroom
1. After deletion, clients receive a
disconnected
event with reason
ROOM_DELETED
. If you meant ending only an AI agent's session (not the whole room), use the agent session shutdown methods: • Python:
session.shutdown(drain=True)
• Node.js/TS:
ctx.shutdown('Session ended')
Which of these do you want to do (delete the whole room or shut down an agent session)? Sources: Connecting to LiveKit | LiveKit docs | Managing rooms | LiveKit docs