How to set room or participant attributes from ser...
# ask-ai
a
How to set room or participant attributes from server API?
t
Thanks for reaching out, Gamal. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'd be happy to guide you through setting room or participant attributes using the LiveKit server API. Here's how you can do it: 1. Setting Participant Attributes: • You can use the
RoomService.UpdateParticipant
API to update key-value string attributes for a participant. • For example, in Ruby:
Copy code
client.update_participant(
  room: 'room_name',
  identity: 'participant_identity',
  attributes: { 'key' => 'value' }
)
• If you want to delete an attribute, just set its value to an empty string (
''
). 2. Setting Room Metadata: • When creating a room, you can set metadata using the
CreateRoom
API. • To update metadata for an existing room, use the
UpdateRoomMetadata
API. 3. Initial Attributes via Access Token: • You can also set initial participant attributes and metadata right in the token payload when you generate an access token. Limits and Best Practices: • Keep in mind that attributes and metadata have a size limit of 64 KiB. • If you need to update information frequently, it’s better to use data packets instead of attributes or metadata for efficiency. If you have any questions or need a hand with anything else, please don’t hesitate to ask. I’m here to help! Sources: Participant attributes and metadata | LiveKit Docs | lib/livekit/access_token.rb | packages/livekit-server-sdk/src/AccessToken.ts | Room metadata | LiveKit Docs | room.go