Actions100
- Activity Actions
- Asset Actions
- Authentication Actions
- Collection Actions
- Extension Actions
- Field Actions
- File Actions
- Folder Actions
- Item Actions
- Permission Actions
- Preset Actions
- Relation Actions
- Revisions Actions
- Roles Actions
- Settings Actions
- Users Actions
- Utilities Actions
Overview
The Directus node for n8n, when configured with the Resource: Roles and Operation: Create Multiple, allows you to create multiple user roles in a Directus instance in a single API call. This is particularly useful for bulk setup or migration scenarios where several roles need to be defined at once, such as initializing a new project, synchronizing environments, or automating onboarding processes.
Practical examples:
- Setting up standard roles (e.g., "Admin", "Editor", "Viewer") during initial deployment.
- Migrating role definitions from one Directus environment to another.
- Automating the creation of custom roles for different departments or user groups.
Properties
Name | Type | Meaning |
---|---|---|
Data (JSON) | json | An array of partial role objects. Each object defines the properties of a role to be created, such as name , icon , description , admin_access , and app_access . This property is required. |
Output
- The output will be an array of JSON objects, each representing a newly created role in Directus.
- Each object contains the details of the created role, typically including fields like
id
,name
,icon
,description
,admin_access
,app_access
, and any other relevant role attributes as returned by the Directus API.
Example output:
[
{
"id": "abc123",
"name": "Interns",
"icon": "verified_user",
"description": null,
"admin_access": false,
"app_access": true,
...
},
{
"id": "def456",
"name": "Customers",
"icon": "person",
"description": null,
"admin_access": false,
"app_access": false,
...
}
]
Note: The actual fields depend on your Directus version and configuration.
Dependencies
- Directus API: You must have access to a running Directus instance.
- API Credentials: The node requires valid Directus API credentials (
directusApi
) to authenticate requests. - n8n Configuration: Ensure that the Directus node is properly configured with the correct API URL and credentials in n8n.
Troubleshooting
Common issues:
- Invalid JSON in Data (JSON): If the input is not valid JSON, the node will throw a parsing error. Double-check your JSON syntax.
- Missing Required Fields: Each role object may require certain fields (like
name
). Omitting these can result in API errors. - Insufficient Permissions: The API credentials used must have permission to create roles. Otherwise, you may receive authorization errors.
- Duplicate Role Names: Attempting to create roles with names that already exist may cause conflicts, depending on your Directus settings.
Error messages and resolutions:
"Unexpected token ... in JSON"
: Check your JSON formatting in the Data (JSON) field."Missing required property: name"
: Ensure every role object includes aname
property."401 Unauthorized"
or"403 Forbidden"
: Verify your API credentials and permissions."409 Conflict"
: A role with the same unique property (e.g., name) already exists.