I would like to create a sync job, that takes users from an external system, and creates them as users of a datasource, under a specific role:
I am struggelig to find a proper API/other way to add users programmatically into these groups.
At this time, this is not possible. It is not available as a Power BI REST API, as seen in the Power BI REST API Datasets reference, since RLS is a dataset feature.
A workaround this issue would be to bind an Active Directory group to a RLS role, so you can add programatically users to this AD group and it would be reflected to the Power BI Dataset.
There is an idea on Power BI Ideas Forum that requests this feature, along with the need to create roles within the REST API.