How did you assign permissions to a Editor role from the code

System Information
  • Strapi Version: 3.6.8
  • Operating System:
  • Database:
  • Node Version: v14.17.6
  • NPM Version: 6.14.15
  • Yarn Version: 1.22.15

Since you assigned permissions to a role from the code, I need to get all the name fields of the content types like “properties”:{“fields”:[“author”,“category”,“content”,“description”,“image”,“slug”,“title”],“locales”:[“en”]},

(global.strapi.contentTypes) to save {

const generateRowPermission = (action, subject) => {
return {
properties: { fields: [‘title’], locales: [‘en’] },
conditions: [],
role: 2
const actions = [
const permission = generateRowPermission(action, value.uid);
await strapi.query(‘permission’, ‘admin’).create(permission);

stumbled upon a snippet earlier this day which sets permissions, locales and other stuff at bootstrap-time.
maybe this helps you a little bit.

No, the permissions that I want to add from the code are these:

Same logic applies (roughly) but the permissions structure of the admin are a bit different in that if there is no permission it’s not created in the database.

Here is an example screenshot from a test project I was playing with (table is called strapi_permission)

And you would need to use the strapi.query('permission', 'admin').create({ ... data })

The structure of these permissions is much more complex than the users-permissions (and we don’t have them documented). There are 3 models in the admin “plugin” (it’s not a plugin but in the internal API it’s treated as one):

  • user
  • permission
  • role

You can use the yarn strapi console to explore the internal API and see what functions exist: