How to add custom meta data in createsip participa...
# ask-ai
c
How to add custom meta data in createsip participant
t
Thanks for reaching out, ZaidKaraymeh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Hey there! If you want to add some custom metadata when creating a SIP participant, you can use the
participant_metadata
parameter. This lets you attach your own info to the SIP participant right when you create them. Using the Node.js SDK:
Copy code
const sipClient = new SipClient(host, apiKey, secret);

await sipClient.createSipParticipant(
  trunkId,
  phoneNumber,
  roomName,
  {
    participantMetadata: '{"custom_field": "value", "user_type": "external"}',
    // other options...
  }
);
Direct API Call: Just include the
participant_metadata
field in your request like this: • Parameter:
participant_metadata
Type: String • Description: Your own metadata attached to the participant you’re creating Quick heads up: the metadata is usually stored as JSON, but you can use any string format you like. It’ll be visible to other participants in the room and you can access it through the participant object. Hope that helps! Sources: SIP APIs | LiveKit Docs | protobufs/livekit_sip.proto | packages/livekit-server-sdk/src/SipClient.ts | SIP dispatch rule | LiveKit Docs
c
Python sdk
t
Hey there! If you want to add some custom metadata when creating a SIP participant using the Python SDK, you can easily do that with the
participant_metadata
parameter in the
CreateSIPParticipantRequest
. Here's a quick example to get you started:
Copy code
from livekit import api

# Create the request with custom metadata
response = await livekit_api.sip.create_sip_participant(
    api.CreateSIPParticipantRequest(
        sip_trunk_id="your_trunk_id",
        sip_call_to="+1234567890",
        room_name="your_room_name",
        participant_identity="sip_participant",
        participant_name="SIP Caller",
        participant_metadata='{"custom_field": "value", "user_id": "12345"}',  # Custom metadata as JSON string
        participant_attributes={
            "task": "customer_support",
            "department": "sales"
        }
    )
)
Here are a few key things to keep in mind:Data Type: The
participant_metadata
should be a string. • Format: It can be any string, but it’s usually a JSON string to keep things organized. • Usage: This is your chance to add any custom info that’s meaningful for your app. If you have any questions or want to dive deeper, just let me know — I’m here to help! Sources: livekit-rtc/livekit/rtc/participant.py | SIP APIs | LiveKit Docs | SIP dispatch rule | LiveKit Docs