how to set max_duration for sip outbound calls .
# ask-ai
s
how to set max_duration for sip outbound calls .
t
Thanks for reaching out, Harsh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you set the maximum duration for SIP outbound calls, you can use the
max_call_duration
parameter when creating a SIP participant through the
CreateSIPParticipant
API. This parameter lets you specify the maximum call length in seconds, and once that time is reached, the call will automatically end. Here’s a friendly example using the Node.js SDK to guide you:
Copy code
const participant = await client.createSipParticipant({
  sipTrunkId: 'trunk-id',
  sipCallTo: '+1234567890',
  roomName: 'my-room',
  maxCallDuration: 3600 // 1 hour in seconds
});
Just a quick note: the maximum duration is capped at 24 hours on the server side. If you’d like more help or examples in other SDKs, please don’t hesitate to ask—I’m here to support you! Sources: SIP APIs | LiveKit Docs | pkg/sip/participant.go | packages/livekit-server-sdk/src/SipClient.ts | lib/livekit/sip_service_client.rb | livekit-protocol/livekit/protocol/sip.pyi
s
i am creating sip participant with cli .
t
I wanted to let you know that there isn’t a dedicated LiveKit CLI tool specifically for setting the
max_call_duration
on SIP outbound calls just yet. But don’t worry—you can still set this by making a direct API call to the
CreateSIPParticipant
endpoint or by using one of our supported SDKs like Node.js, Python, or Ruby. If you happen to be using a custom CLI wrapper around LiveKit’s API, just double-check that it supports the
max_call_duration
parameter. If not, here’s a handy example of how you can make a direct API call:
Copy code
curl -X POST <YOUR_LIVEKIT_API_URL>/twirp/livekit.SIP/CreateSIPParticipant \
  -H "Authorization: Bearer <your-access-token>" \
  -H "Content-Type: application/json" \
  -d '{
    "sip_trunk_id": "your-trunk-id",
    "sip_call_to": "+1234567890",
    "room_name": "your-room-name",
    "max_call_duration": "3600s"
  }'
If you’d like, I’m here to help with more examples or guide you through using a specific SDK—just let me know! Sources: livekit-protocol/src/livekit.rs | pkg/sip/participant.go | SIP APIs | LiveKit Docs | protobufs/rpc/io.proto | lib/livekit/sip_service_client.rb