Managing rooms

Create, list, and delete Rooms from your backend server.

Initialize RoomServiceClient

Room management is done with a RoomServiceClient, created like so:

import (
lksdk "github.com/livekit/server-sdk-go"
livekit "github.com/livekit/protocol/livekit"
)
// ...
host := "https://my.livekit.host"
roomClient := lksdk.NewRoomServiceClient(host, "api-key", "secret-key")

Create a room

room, _ := roomClient.CreateRoom(context.Background(), &livekit.CreateRoomRequest{
Name: "myroom",
EmptyTimeout: 10 * 60, // 10 minutes
MaxParticipants: 20,
})

List rooms

rooms, _ := roomClient.ListRooms(context.Background(), &livekit.ListRoomsRequest{})

Delete a room

Deleting a room causes all Participants to be disconnected.

_, _ = roomClient.DeleteRoom(context.Background(), &livekit.DeleteRoomRequest{
Room: "myroom",
})