Directus Roles and Permissions Setup

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1 servicesAll 2065 services
Directus Roles and Permissions Setup
Simple
from 1 business day to 3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1170
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1094
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    830
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    879
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    453

Setting Up Roles and Permissions in Directus

Directus uses a role-based access model. Each user is assigned to a role, and the role receives a set of permissions on collections: read, create, update, delete. Permissions can be full or conditional (only own records, only specific fields).

Roles

In Settings → Roles & Permissions → create a role:

  • Administrator — full access (built-in)
  • Public — unauthenticated requests (built-in)
  • Editor — content management
  • Author — only own materials
  • API Client — read-only for external frontend

Programmatic Role Management

// Via Directus SDK
import { createDirectus, rest, authentication, createRole, createPermission } from '@directus/sdk'

const directus = createDirectus(DIRECTUS_URL).with(rest()).with(authentication())
await directus.login(ADMIN_EMAIL, ADMIN_PASSWORD)

// Create role
const editorRole = await directus.request(createRole({
  name: 'Editor',
  admin_access: false,
  app_access: true,  // access to admin panel
}))

// Assign permissions
await directus.request(createPermission({
  role: editorRole.id,
  collection: 'articles',
  action: 'read',
  // null = all records
}))

await directus.request(createPermission({
  role: editorRole.id,
  collection: 'articles',
  action: 'create',
}))

await directus.request(createPermission({
  role: editorRole.id,
  collection: 'articles',
  action: 'update',
  // Only own articles
  permissions: { user_created: { _eq: '$CURRENT_USER' } },
  fields: ['*'],  // all fields
}))

Field-level Permissions

// Only specific fields are accessible for reading
await directus.request(createPermission({
  role: authorRoleId,
  collection: 'articles',
  action: 'read',
  fields: ['id', 'title', 'slug', 'content', 'status'],
  // Hidden fields: internal_notes, revenue_impact
}))

Item-level Permissions with Filter

// Editor sees only published articles plus own drafts
await directus.request(createPermission({
  role: editorRoleId,
  collection: 'articles',
  action: 'read',
  permissions: {
    _or: [
      { status: { _eq: 'published' } },
      { user_created: { _eq: '$CURRENT_USER' } },
    ],
  },
}))

Public Role (for Public API)

// Public read of published articles
await directus.request(createPermission({
  role: null,  // null = Public role
  collection: 'articles',
  action: 'read',
  permissions: { status: { _eq: 'published' } },
  fields: ['id', 'title', 'slug', 'content', 'publishedAt', 'thumbnail'],
}))

Static Token for Server Requests

# Admin → Users → select user → Token field
# Create user with "API Client" role (read-only)
# Set static token
// Using static token
const response = await fetch(`${DIRECTUS_URL}/items/articles?filter[status][_eq]=published`, {
  headers: { Authorization: `Bearer ${STATIC_TOKEN}` },
})

Timeline

Setting up a roles system for editorial team (3–5 roles) — 0.5–1 day.