how can i attach permission with LocalAudioTrack s...
# ask-ai
n
how can i attach permission with LocalAudioTrack such that only some participant can subscribe that audioTrack ?
t
Thanks for reaching out, Darshak. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking how to make a LocalAudioTrack subscribable only by certain participants. You can control this using track subscription permissions on the publisher's LocalParticipant with
setTrackSubscriptionPermissions
. Permissions apply to all tracks published by that participant (not per individual track). How to do it 1. Call
setTrackSubscriptionPermissions
on the local participant. 2. Set
allParticipantsAllowed
to
false
. 3. Provide a list of participant permissions specifying which participants may subscribe (by identity or SID) and whether they can subscribe to all tracks. Examples • JavaScript
Copy code
localParticipant.setTrackSubscriptionPermissions(false, [
  { participantIdentity: 'allowed-identity', allTracksAllowed: true },
]);
• Kotlin (Android)
Copy code
localParticipant.setTrackSubscriptionPermissions(
  allParticipantsAllowed = false,
  listOf(ParticipantTrackPermission(participantIdentity = "allowed-identity", allTracksAllowed = true))
)
• Swift (iOS)
Copy code
localParticipant.setTrackSubscriptionPermissions(
  allParticipantsAllowed: false,
  trackPermissions: [
    ParticipantTrackPermission(participantSid: "allowed-sid", allTracksAllowed: true)
  ]
)
• Python
Copy code
local_participant.set_track_subscription_permissions(
  all_participants_allowed=False,
  participant_permissions=[
    rtc.ParticipantTrackPermission(participant_identity="allowed-identity", allow_all=True),
  ],
)
Notes and important details • These permissions control subscription for all tracks published by that participant. Per-track restrictions are not provided directly; for per-track behavior you must enforce it at the application level (e.g., by publishing/unpublishing or using signaling). • Subscribers also require
canSubscribe: true
in their access token to be allowed to subscribe. If you want, tell me which client/platform (JS, iOS, Android, Flutter, or server SDK) you're using and whether you need per-track behavior—I can provide a tailored code example or an app-level pattern for per-track control. Sources: Camera & microphone | LiveKit docs | server-sdk-js | livekit/livekit_composite | DeepWiki
n
Issue: Track subscription control for inbound & outbound SIP participants I create an inbound SIP call, then publish two local tracks via the Agent: •
Inbound_Local_Track
•
Outbound_Local_Track
After that, I add an outbound SIP participant using
ctx.add_sip_participant
in the same room. Expected: • Inbound participant subscribes only to
Outbound_Local_Track
• Outbound participant subscribes only to
Inbound_Local_Track
Working: Unsubscribing tracks for the inbound participant using
lk.room.update_subscriptions
works as expected. Problem: The same
update_subscriptions
call does *not work for the outbound SIP participant*—it still receives unwanted tracks. Is there any limitation with SIP participants added via
ctx.add_sip_participant
, or a recommended way to enforce one-way track subscriptions between inbound and outbound SIP participants?
t
Thanks — I’m responding about enforcing one-way subscriptions between your inbound and outbound SIP participants added via
ctx.add_sip_participant
. Short answer: there is no inherent limitation that prevents controlling subscriptions for SIP participants added with
ctx.add_sip_participant
. Use the room-level
update_subscriptions
call for each SIP participant, ensuring you target the exact participant identity (or SID) created for the outbound SIP participant and that the caller has room-admin privileges. Checklist to verify and steps to try 1. Confirm identities ◦ Verify the exact identity (or participant SID) of the outbound SIP participant created by
ctx.add_sip_participant
. Use that exact identity value when calling
update_subscriptions
. 1. Call
update_subscriptions
per participant ◦ For inbound participant: set subscriptions to only the outbound track SID. ◦ For outbound participant: set subscriptions to only the inbound track SID. ◦ Example pattern (Python-like):
Copy code
# inbound subscribes only to outbound track
     lkapi.room.update_subscriptions(room=room.name, identity=inbound_identity, track_sids=[OUTBOUND_TRACK_SID], subscribe=True)

     # outbound subscribes only to inbound track
     lkapi.room.update_subscriptions(room=room.name, identity=outbound_identity, track_sids=[INBOUND_TRACK_SID], subscribe=True)
1. Ensure caller permissions ◦ The process calling
update_subscriptions
must have room-admin (or equivalent) privileges so the RPC can change other participants’ subscriptions. 1. Check auto-subscribe / defaults ◦ If auto-subscribe behavior or token-level
canSubscribe
flags exist for the SIP participant, ensure those aren’t allowing extra subscriptions. Explicitly unsubscribe unwanted tracks if needed. 1. Verify timing and SIDs ◦ Make sure track SIDs used in
track_sids
are the actual published track SIDs at the time you call
update_subscriptions
. If you call too early (before the outbound participant or track is fully added), the update may not stick. If you’ve checked the above and the outbound SIP participant still receives unwanted tracks, tell me: • the exact identity or participant SID of the outbound SIP participant, • the track SIDs you’re using, • which SDK/language and API call you’re making (exact
update_subscriptions
parameters), and I’ll help narrow down the cause and next steps. Sources: Make outbound calls | LiveKit docs | Agents telephony integration | LiveKit docs | Subscribing to tracks | LiveKit docs | Managing participants | LiveKit docs
n
is there any other way around to join outbound participant currently what i am doing after inbound participant make call in room i am doing ctx.add_sip_participant()
t
You're asking for alternatives to using
ctx.add_sip_participant()
to bring the outbound SIP participant into the room. Two viable alternatives and guidance: Options • Use SIP dial-out instead of add: initiate an outbound SIP call from the agent/server with a dial API (e.g.,
ctx.dial_sip
or equivalent) so the outbound leg is created as a normal SIP call and joined into the room. This can simplify subscription timing because the dial flow mirrors how the inbound call was created. • Create the SIP participant via the server SDK create method: use the room-level SDK RPC (often named
create_sip_participant
/
add_sip_participant
variant in server SDKs) from a room-admin context so you control identity, token flags, and timing explicitly before publishing tracks. Practical tips to reduce subscription issues • Create or join the outbound participant first (or ensure it exists) before publishing the two local tracks, so you can set subscriptions after both participant and tracks are present. • Use precise participant identity or participant SID when calling
update_subscriptions
. • Wait until the outbound participant and the relevant track SIDs are present (listen for participant/track-added events) before applying
update_subscriptions
. • Ensure the caller has room-admin privileges and that the outbound SIP participant’s token
canSubscribe
flag isn’t permitting extra subscriptions. • If per-track control is required, enforce it at the app layer (only publish desired tracks to a given leg, or unpublish/re-publish as needed). Quick question to recommend the best path: which server SDK/language are you using, and do you currently create the outbound SIP participant immediately after the inbound call or after publishing the two tracks?
n
is there any api so that i can update remote participant track permissions ?
t
You're asking if there's an API to update a remote participant's track subscription permissions. Short answer and guidance: • There is no direct server API to set another participant's track subscription permissions. Track subscription permissions are set by the publisher via
setTrackSubscriptionPermissions
on the publisher's LocalParticipant. • From the server you can still: ◦ Call moderation actions like
mutePublishedTrack()
or
removeParticipant()
to control media flow. ◦ Use
update_subscriptions
(room-level RPC) to control which tracks a given participant is subscribed to — this operates from the room admin side and targets subscriptions for that participant. • If you need per-track, publisher-enforced control (not per-publisher-all-tracks), enforce at the application level: publish/unpublish specific tracks, or have the publisher call
setTrackSubscriptionPermissions
with per-participant
ParticipantTrackPermission
entries. To give a precise code pattern, which side and SDK are you calling from now — publisher client (JS/iOS/Android/Flutter) or server SDK (Python/Node/Go)? Also tell me whether you need per-track restrictions or per-publisher restrictions. Sources: Camera & microphone | LiveKit docs | Managing participants | LiveKit docs