# permissionsChanged

When a user gives/revokes your broadcast or screenshare permissions, then the **permissionsChanged** event will be emitted. Such users are typically moderators who are capable of managing other users' permissions.

{% hint style="info" %}
Typical use-case for listening to this event is to show camera and microphone icons in your custom toolbar when the user receives permissions to broadcast.
{% endhint %}

#### Sample payload

```json
{
    "type": "permissionsChanged",
    "data": {
       "broadcast": true,           // Legacy field, true if either audio or video is allowed
       "broadcastAudio": true,      // New field, true if audio broadcasting is allowed
       "broadcastVideo": true,      // New field, true if video broadcasting is allowed
       "screenshare": true
    }
}
```

#### Sample subscription code

```javascript
sambaFrame.on('permissionsChanged', (event) => {
  const data = event.data;
  
  if (data.broadcast !== undefined) {
    if (data.broadcast) {
      console.log('You were granted broadcast permission')
    } else {
      console.log('Your permission to broadcast was revoked')
    }
  }
  
  // New way - using granular broadcast permissions
  if (data.broadcastAudio !== undefined) {
    if (data.broadcastAudio) {
      console.log('You were granted audio broadcast permission')
    } else {
      console.log('Your audio broadcast permission was revoked')
    }
  }

  if (data.broadcastVideo !== undefined) {
    if (data.broadcastVideo) {
      console.log('You were granted video broadcast permission')
    } else {
      console.log('Your video broadcast permission was revoked')
    }
  }

  if (data.screenshare !== undefined) {
    if (data.screenshare) {
      console.log('You were granted screenshare permission')
    } else {
      console.log('Your permission to screenshare was revoked')
    }
  }
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.digitalsamba.com/reference/sdk/events/permissionschanged.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
