Modifying Roles and Permissions on the Fly with the Digital Samba SDK
The Digital Samba SDK lets you modify participant roles and permissions during a live video call, straight from your own code. You can grant or revoke broadcast and screen-share rights, mute participants, ask them to unmute, promote an attendee to moderator mid-session and check what the local user is allowed to do. This guide walks through each method with working code examples.
Table of contents- What are roles and permissions?
- Modifying roles with the Digital Samba SDK
- Granting and revoking broadcast permission
- Remote mute and requests to unmute
- Allowing or disallowing screen sharing
- Changing roles
- Checking permissions with permissionManager
- Conclusion
- FAQ: Managing roles with the Digital Samba SDK
What are roles and permissions?
Roles and permissions decide what each participant can do in a video conference: who controls the microphones, who can share a screen, who can record and who can remove a disruptive participant.
A role is a named set of permissions that defines a participant's access level, from full control as a moderator to view-focused access as an attendee. Digital Samba ships with preset roles – moderator, speaker and attendee – and you can create custom roles with their own permission sets through the API or the dashboard, as we show in our guide to custom roles in the Digital Samba dashboard.
Permissions you can grant or check from the SDK include, among others:
- Broadcast, and manage other users' broadcast permissions
- Start and end the session
- Remove participants
- Share screen, and manage screen-share permissions
- Record the session
- Write in the general chat
- Mute remote users and ask them to unmute
- Raise hand
- Manage roles
This level of control lets you shape the call to the situation – a small team meeting where everyone broadcasts, or a large webinar where only a few people do.
Modifying roles with the Digital Samba SDK
Roles are assigned when a room is created or when participants join with a token. The SDK adds the runtime layer on top: its methods and events let you adjust roles and permissions while the session is running, which is exactly what you need for a custom participants panel or moderator controls in your own interface. With the SDK you can programmatically:
- Grant and revoke broadcast permissions
- Mute remote users and ask them to unmute
- Allow or disallow screen sharing
- Change a participant's role
- Check the local user's permissions
Prerequisites:
- A Digital Samba developer account (sign up here)
- The Digital Samba Embedded SDK integrated into your page – see the integration guide or our walkthrough on how to integrate video conferencing into your website
- Basic knowledge of JavaScript or TypeScript
In the examples below, sambaFrame is your initialised SDK instance, and the user IDs come from the listUsers() method or from events such as userJoined.
1. Granting and revoking broadcast permission
The allowBroadcast() method grants broadcast permissions to a target user – useful in webinar scenarios where most participants cannot broadcast by default. You pass the user's ID along with the specific permissions to grant: audio, video or both (at least one must be true).
// Grant both microphone and camera
sambaFrame.allowBroadcast({
id: '9efc7798-a1a4-44bd-9d8d-532fe0feea9d',
audio: true,
video: true
});
// Audio only – the user can speak but not be seen
sambaFrame.allowBroadcast({
id: '9efc7798-a1a4-44bd-9d8d-532fe0feea9d',
audio: true,
video: false
});
This granularity is handy when you want some participants to speak (audio only) while others can both speak and appear on camera. The older format allowBroadcast(userId), which grants both at once, still works but is deprecated.
To revoke broadcast permission, call disallowBroadcast() with the user's ID:
sambaFrame.disallowBroadcast('9efc7798-a1a4-44bd-9d8d-532fe0feea9d');
Note: disallowBroadcast() only takes effect if allowBroadcast() was previously called for that user.
2. Remote mute and requests to unmute
The requestMute() method mutes a remote participant's microphone. Pass the user's ID, and a confirmation popup is shown inside the session so nobody gets muted by accident:
sambaFrame.requestMute('9efc7798-a1a4-44bd-9d8d-532fe0feea9d');
A typical use: a moderator silences background noise from a participant's microphone with one click in your custom participants panel.
To ask a muted participant to speak again, use requestUnmute(). The participant sees a popup and can accept or deny the request:
sambaFrame.requestUnmute('9efc7798-a1a4-44bd-9d8d-532fe0feea9d');
Note: you cannot force an unmute – that would be a privacy problem. The participant always has to agree before their microphone turns on.
There is also a combined method, requestToggleAudio(), which flips the remote user's microphone state, or sets it explicitly with an optional second parameter:
// Toggle the microphone state
sambaFrame.requestToggleAudio('9efc7798-a1a4-44bd-9d8d-532fe0feea9d');
// true = mute, false = ask the user to unmute
sambaFrame.requestToggleAudio('9efc7798-a1a4-44bd-9d8d-532fe0feea9d', true);
3. Allowing or disallowing screen sharing
The allowScreenshare() method grants screen-share permission to a specific user, who can share their screen as soon as it is called:
sambaFrame.allowScreenshare('9efc7798-a1a4-44bd-9d8d-532fe0feea9d');
This is useful where certain roles have no screen-share permission by default – a webinar, for instance – and a moderator grants it selectively to a presenter.
The reverse, disallowScreenshare(), revokes the permission, and like its broadcast counterpart it only takes effect if allowScreenshare() was previously called for that user:
sambaFrame.disallowScreenshare('9efc7798-a1a4-44bd-9d8d-532fe0feea9d');
4. Changing roles
The changeRole() method changes a user's role entirely, taking the user's ID and the new role name as parameters. For example, to promote a user to moderator and later demote them to attendee:
// Promote a user to moderator
sambaFrame.changeRole('9efc7798-a1a4-44bd-9d8d-532fe0feea9d', 'moderator');
// Demote the moderator to attendee later
sambaFrame.changeRole('9efc7798-a1a4-44bd-9d8d-532fe0feea9d', 'attendee');
When a role changes, the SDK emits the roleChanged event – useful for keeping a custom participants panel up to date. Subscribe with on():
sambaFrame.on('roleChanged', (event) => {
const data = event.data;
console.log('User', data.userId, 'role changed from', data.from, 'to', data.to);
});
The payload tells you who changed and between which roles:
{
"type": "roleChanged",
"data": {
"userId": "2775f882-845e-4416-82c9-04cc25669c0b",
"from": "attendee",
"to": "moderator"
}
}
5. Checking permissions with permissionManager
The permissionManager property gives you a module for checking permissions. Its hasPermissions() method tells you whether the local user holds one or more specific permissions, using the PermissionTypes values:
enum PermissionTypes {
broadcast = 'broadcast',
manageBroadcast = 'manage_broadcast',
endSession = 'end_session',
startSession = 'start_session',
removeParticipant = 'remove_participant',
screenshare = 'screenshare',
manageScreenshare = 'manage_screenshare',
recording = 'recording',
generalChat = 'general_chat',
remoteMuting = 'remote_muting',
askRemoteUnmute = 'ask_remote_unmute',
raiseHand = 'raise_hand',
manageRoles = 'manage_roles',
}
Here's how to check whether the local user can broadcast:
const canBroadcast = sambaFrame.permissionManager.hasPermissions('broadcast');
console.log('Local user can broadcast:', canBroadcast);
The optional HasPermissionsOptions object narrows the check – you can specify a target role, a user role or a user ID. That makes it easy to build role-aware interfaces: show the 'Mute all' button only to users who hold remote_muting, for example.
For the full list of role and permission methods, see the SDK documentation.
Conclusion
With a handful of SDK methods – allowBroadcast(), requestMute(), allowScreenshare(), changeRole() – and the roleChanged event, you can build moderator controls and custom participants panels that adjust who can do what, live, without anyone leaving the call. Combine them with permissionManager checks so each user only sees the controls their role allows.
If you want to go further, our guides on selecting and switching participants in a Digital Samba video call and joining and controlling the embedded video conference with the SDK cover the surrounding workflow.
FAQ: Managing roles with the Digital Samba SDK
1. Can I change a participant's role during a live session?
Yes. Call changeRole() with the participant's user ID and the new role name, and the change applies immediately. The SDK then emits the roleChanged event, so your interface can update in real time.
2. Can I force-unmute a participant with the SDK?
No. Forcing a microphone on would be a privacy problem, so requestUnmute() and requestToggleAudio() only send the participant a request. They see a popup and decide whether to accept or deny it.
3. What is the difference between allowBroadcast() and changeRole()?
allowBroadcast() grants one specific capability – audio, video or both – to one user without touching their role. changeRole() switches the user to a different role, which replaces their whole permission set at once.
4. Do these SDK methods work with custom roles?
Yes. changeRole() accepts any role name available in the room, including custom roles you have created via the REST API or the dashboard. Permission checks with permissionManager work the same way for preset and custom roles.
5. How do I check what the local user is allowed to do?
Use permissionManager.hasPermissions() with one or more PermissionTypes values, such as broadcast or remote_muting. It returns whether the local user holds those permissions, so you can show or hide controls accordingly.
6. Where do the user IDs in these examples come from?
The SDK gives you participant IDs through the listUsers() method and through events such as userJoined and roleChanged. Store them in your participants panel and pass them to the role and permission methods.
Share this
You May Also Like
These Related Stories

How to Embed Video Conferencing on Your Website in Four Steps

Get started with Digital Samba Embedded: rooms and sessions

