GitHub user dosubot[bot] added a comment to the discussion: Create role using 
API

<!-- Answer -->
Superset exposes REST API endpoints for role management and permission 
assignment. Here’s how you can achieve your workflow:

- List roles:  
  `GET /api/v1/security/roles/search`  
  This returns all roles, supports filtering, and pagination.  
  Example:  
  ```
  GET 
/api/v1/security/roles/search?q={"filters":[{"col":"name","opr":"eq","value":"YourRoleName"}]}
  ```

- Create a role:  
  `POST /api/v1/security/roles/`  
  Payload:  
  ```json
  { "name": "YourRoleName" }
  ```

- List all permissions (for datasets, charts, dashboards):  
  `GET /api/v1/security/permissions-resources/`  
  This returns PermissionViewMenu (PVM) objects. Filter for the ones you want 
(e.g., dataset access, dashboard access).

- Assign permissions to a role:  
  `POST /api/v1/security/roles/{roleId}/permissions`  
  Payload:  
  ```json
  { "permission_view_menu_ids": [list_of_pvm_ids] }
  ```
  Use the IDs from the previous step for datasets, charts, and dashboards you 
want this role to access.

- Restrict dataset access role-wise:  
  Only assign the dataset PVMs you want the role to access. Users with this 
role will only see those datasets.

You can also update users or groups for a role if needed.  
For more details, see the implementation in the codebase 
([example](https://github.com/apache/superset/blob/98b35125c2a562bb2a61a26e6acd3430339320aa/superset-frontend/src/features/roles/utils.ts)).

This API-driven approach lets you automate fine-grained, role-based access 
control for datasets, charts, and dashboards. If you need row-level security, 
Superset also supports that via separate constructs.


<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/227bc240-3890-49f7-96cc-404ad9712068?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/227bc240-3890-49f7-96cc-404ad9712068?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/227bc240-3890-49f7-96cc-404ad9712068?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/227bc240-3890-49f7-96cc-404ad9712068?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/227bc240-3890-49f7-96cc-404ad9712068?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/227bc240-3890-49f7-96cc-404ad9712068?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/227bc240-3890-49f7-96cc-404ad9712068?feedback_type=other)</sup>&nbsp;&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Sh
 are on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/33878)

GitHub link: 
https://github.com/apache/superset/discussions/33878#discussioncomment-13558797

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to