How can I create administration panel roles programmatically

Here is the situation :

I have a strapi backend application that delivers content to a frontend application. The admin panel can be used by a multitude of users to create / read / modify content depending on an access rights matrix.
The production application should not be accessed using a superadmin of any kind, in fact all the configuration for the application should be done programmatically (one way or another), no GUI should be involved, meaning that the roles should be created when the application starts.

I know this kind of operation is possible for the Users & Permissions plugins for API access but I haven’t seen such thing for the roles related to the admin panel, is there **any **way to do so ?

This topic has been created from a Discord post (1228299706766196807) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

You could use the config-sync plugin. But that would still require you to configure everything through the GUI locally. After you’ve set it up though, you can just export everything and import it on other envs to programatically create/update/delete the admin roles.

But I’m not sure if that’s what you’re after

That’s an interesting idea <@344388867446669315> thanks for the response, I’m gonna try it out

I successfully configured the plugin and import export works perfectly, however it seems importOnBootstrap does not function for some reason, have you encountered this error before ?

Nvm, didn’t see this one : [2024-04-14 14:32:43.949] warn: [strapi-plugin-config-sync]: You can’t use the ‘importOnBootstrap’ setting in the development env.

Yeah, it’s a failsafe. You should only use that feature on non-development environments.

I understand, great work btw, very easy to use and the feature is definitely useful !!

i just write them directly to the db via an external migration tool and bypass strapi entirely

Whatever floats your code :smile: