narrow-chef-71655
12/12/2025, 6:19 AMtall-airline-16756
12/12/2025, 6:19 AMtall-airline-16756
12/12/2025, 6:19 AMsetTrackSubscriptionPermissions()) on their own published tracks to allow or deny specific participants (or all participants) from subscribing to those tracks.
• Disable global subscriptions and selectively permit identities to subscribe to camera/mic tracks.
Summary:
• ❌ You cannot control another participant's subscriptions for tracks they receive.
• ✅ You can control who is permitted to subscribe to your own published tracks. Sources: Subscribing to tracks | LiveKit docs | Camera & microphone | LiveKit docsnarrow-chef-71655
12/12/2025, 8:22 AMtall-airline-16756
12/12/2025, 8:23 AMnarrow-chef-71655
12/12/2025, 8:29 AMtall-airline-16756
12/12/2025, 8:29 AMsetTrackSubscriptionPermissions / set_track_subscription_permissions):
◦ Set allParticipantsAllowed = false to block everyone by default.
◦ Add allow-rules for specific participant identities (including SIP identities) or for specific tracks.
◦ Permissions are enforced server-side, so SIP participants cannot bypass them.
• If you control the SIP client behavior, you can disable autoSubscribe for the SIP participant and programmatically subscribe only to chosen tracks — but this is client-side and not enforcement. Use server-side permissions for guaranteed restrictions.
If you want, tell me:
• which server SDK you use (Node/Python/Go/Java), and
• whether you need per-publisher or per-track rules,
and I’ll provide the exact code snippet.narrow-chef-71655
12/12/2025, 8:31 AMtall-airline-16756
12/12/2025, 8:31 AMawait roomServiceClient.setTrackSubscriptionPermissions('room-name', 'publisher-identity', {
allParticipantsAllowed: false,
trackPermissions: [
{
participantIdentity: 'sip-participant-identity',
allTracksAllowed: true, // or false + trackSids: ['trackSid1','trackSid2']
},
],
});
Python (server SDK)
await publisher.set_track_subscription_permissions(
all_participants_allowed=False,
participant_permissions=[
ParticipantTrackPermission(
participant_identity='sip-participant-identity',
allow_all=True, # or set specific track_sids
),
],
)
Granularity options
• Per-publisher allow-all: permit the SIP participant to subscribe to every track published by that publisher.
• Per-track: permit only specified track SIDs.
• Mixed: different publishers can have different rules.
Notes
• Apply permissions for each publisher whose tracks you want to control.
• SIP participants are treated like normal participants; use their identity in permissions.
• This enforces subscriptions server-side; client-side autoSubscribe changes are not enforcement.
If you tell me which server SDK you use (Node/Python/Go/Java) and whether you need per-publisher or per-track rules, I’ll provide the exact code snippet tailored to your stack.narrow-chef-71655
12/12/2025, 8:33 AMtall-airline-16756
12/12/2025, 8:33 AMconst room = await roomServiceClient.getRoom({ room: 'room-name' });
const pub = room.participants.find(p => p.identity === 'sip-identity');
// published tracks are in pub.tracks
const trackSids = pub.tracks.map(t => t.sid);
1. Use roomServiceClient.setTrackSubscriptionPermissions with trackSids or participantIdentity.
Python (Server SDK / participant object)
room = await room_service.get_room('room-name')
pub = next(p for p in room.participants if p.identity == 'sip-identity')
track_sids = [t.sid for t in pub.tracks]
# then call set_track_subscription_permissions or room service equivalent
await room_service.set_track_subscription_permissions(
room='room-name',
publisher='publisher-identity',
all_participants_allowed=False,
track_permissions=[{
'participant_identity': 'sip-identity',
'track_sids': track_sids
}]
)
Go (RoomService)
• Fetch room via RoomService, find participant via participant.Identity, inspect participant.Tracks for SIDs, then call SetTrackSubscriptionPermissions with either AllTracksAllowed or explicit TrackSids.
Key points
• SIP participants are regular participants; their published tracks appear in the participant object.
• You can reference either the publisher’s identity (to allow all their tracks) or specific `trackSid`s (for per-track rules).
• Use server-side setTrackSubscriptionPermissions (RoomService or participant API) to enforce which SIP participant may subscribe.
If you tell me which server SDK you’re using (Node/Python/Go/Java) and whether you want per-publisher or per-track rules, I’ll provide the exact code snippet for that SDK.narrow-chef-71655
12/12/2025, 8:36 AMtall-airline-16756
12/12/2025, 8:36 AMfrom livekit import RoomServiceClient
room_name = "your-room-name"
sip_identity = "sip-participant-identity" # the SIP participant's identity
room_service = RoomServiceClient() # assume configured with API key/URL
room = room_service.get_room(room=room_name)
participant = next((p for p in room.participants if p.identity == sip_identity), None)
if participant is None:
raise RuntimeError("SIP participant not found in room")
# published track SIDs for this SIP participant
track_sids = [t.sid for t in participant.tracks]
2) Enforce subscription permissions (allow only this SIP participant to subscribe to a publisher's tracks)
• If you want one publisher to allow only that SIP participant to subscribe to their tracks, call set_track_subscription_permissions on the publisher (publisher_identity is the publisher's identity).
Example: allow only a specific SIP participant to subscribe to all tracks from a publisher:
publisher_identity = "publisher-identity"
await room_service.set_track_subscription_permissions(
room=room_name,
publisher=publisher_identity,
all_participants_allowed=False,
participant_permissions=[
{
"participant_identity": sip_identity,
"all_tracks_allowed": True, # allow this SIP participant to subscribe to all publisher tracks
}
],
)
Example: allow only specific track SIDs from a publisher to the SIP participant:
await room_service.set_track_subscription_permissions(
room=room_name,
publisher=publisher_identity,
all_participants_allowed=False,
participant_permissions=[
{
"participant_identity": sip_identity,
"all_tracks_allowed": False,
"track_sids": ["trackSid1", "trackSid2"], # replace with actual SIDs
}
],
)
Notes
• Apply these permissions for each publisher whose tracks you want to control.
• Use the publisher identity to grant access to all that publisher’s tracks, or use track_sids for per-track rules.
• These permissions are enforced server-side and apply to SIP participants just like any other participant.
Would you like a full runnable example (including authentication/config) for the Python SDK, or help listing publishers in the room so you can apply permissions to each?narrow-chef-71655
12/12/2025, 8:38 AMtall-airline-16756
12/12/2025, 8:39 AMLiveKitAPI, not RoomServiceClient. Below are concise, working steps and example code to:
• list participants in a room and find the SIP participant,
• read that participant's published track SIDs,
• enforce server-side subscription permissions so only selected SIP participants may subscribe.
Make sure you have the package:
pip install livekit-api
Example (async Python)
from livekit.api import LiveKitAPI, ListParticipantsRequest, UpdateSubscriptionsRequest
from livekit.protocol.livekit import ParticipantInfo
async def restrict_subscriptions(api_key, api_secret, endpoint, room_name, publisher_identity, allowed_sip_identity, allowed_track_sids=None):
async with LiveKitAPI(api_key, api_secret, endpoint) as lkapi:
# list participants
resp = await lkapi.room.list_participants(ListParticipantsRequest(room=room_name))
participants = resp.participants
# find SIP participant (by identity or kind)
sip = next((p for p in participants if p.identity == allowed_sip_identity or p.kind == ParticipantInfo.Kind.KIND_SIP), None)
if sip is None:
raise RuntimeError("SIP participant not found")
# find publisher to control (by identity)
publisher = next((p for p in participants if p.identity == publisher_identity), None)
if publisher is None:
raise RuntimeError("Publisher not found")
# collect track SIDs from publisher if needed
publisher_track_sids = [t.sid for t in publisher.tracks]
# Decide which tracks to allow for the SIP participant
allowed = allowed_track_sids if allowed_track_sids is not None else publisher_track_sids
# Update subscriptions for the SIP participant (server-side enforcement)
# This example sets subscriptions so the SIP participant receives only `allowed` track SIDs.
await lkapi.room.update_subscriptions(
UpdateSubscriptionsRequest(
room=room_name,
identity=sip.identity,
track_sids=allowed
)
)
Notes
• Use list_participants to inspect participants and their tracks (each has a sid).
• Use update_subscriptions to set exactly which track SIDs a given participant will receive (this enforces server-side).
• If you prefer publisher-centric permissions (allow/deny per-publisher), you can implement equivalent logic by iterating publishers and calling the appropriate Room API methods; the Python SDK exposes room/participant management via LiveKitAPI.
Tell me if you want:
• a non-async (sync) variant,
• a snippet that uses publisher allow-lists instead of update_subscriptions, or
• a full runnable example including authentication setup. Sources: Subscribing to tracks | LiveKit docs | Creating SIP Inbound Trunks and Dispatch Rules with Python SDK