livekit api how to delete a room?
# ask-ai
c
livekit api how to delete a room?
t
Thanks for reaching out, Sai. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
c
lk api
t
To delete a room using the LiveKit API, follow these steps: 1. Initialize the RoomServiceClient: Create an instance of
RoomServiceClient
with your LiveKit host and API credentials. 2. Create a DeleteRoomRequest: Instantiate a
DeleteRoomRequest
object and set the
room
field to the name of the room you want to delete. 3. Call the DeleteRoom method: Use the
DeleteRoom
method of the
RoomServiceClient
to send the request and delete the room. Here’s an example in Python:
Copy code
from google.protobuf.empty_pb2 import Empty
from livekit import api
from livekit.protocol import room as room_proto

# Initialize the LiveKit API client
lkapi = api.LiveKitAPI(
    session=aiohttp.ClientSession(),
    url=BASE_API_URL,  # Replace with your LiveKit host URL
    api_key="your-api-key",  # Replace with your API key
    api_secret="your-api-secret"  # Replace with your API secret
)

# Create a DeleteRoomRequest
delete_request = room_proto.DeleteRoomRequest(
    room="your-room-name"  # Replace with the name of the room to delete
)

# Delete the room
await lkapi.room.delete_room(delete_request)
Replace
BASE_API_URL
,
"your-api-key"
, and
"your-api-secret"
with your actual LiveKit credentials and host URL. Replace
"your-room-name"
with the name of the room you want to delete. Note: The
DeleteRoom
operation requires the
roomCreate
permission. This method will disconnect all participants and remove the room from the server.