Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Roles → Create

AI-generated

Overview

The Directus (DrWade) n8n node for the resource Roles with the operation Create allows you to create a new role in your Directus instance. This is useful for automating user management workflows, such as provisioning new roles for different teams or access levels within your application.

Common scenarios:

  • Automatically creating roles when onboarding new departments or user groups.
  • Integrating role creation into CI/CD pipelines for environment setup.
  • Managing permissions and access control dynamically from n8n workflows.

Practical example:
Suppose your organization hires interns and you want to automate the process of adding an "Interns" role with specific permissions. You can use this node to create that role programmatically as part of your onboarding workflow.


Properties

Name Type Meaning
Data (JSON) json A partial role object. This should include properties such as name, icon, description, admin_access, app_access, etc., defining the characteristics and permissions of the new role.

Output

The output will be a JSON object representing the newly created role. The structure typically includes fields such as:

{
  "id": "unique-role-id",
  "name": "Interns",
  "icon": "verified_user",
  "description": null,
  "admin_access": false,
  "app_access": true,
  // ...other role properties as defined by Directus
}
  • All properties returned are those supported by the Directus Role API.
  • If there is an error and "Continue On Fail" is enabled, the output will contain an error field with the error message.

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure the directusApi credentials in n8n with appropriate permissions to create roles.

Troubleshooting

Common issues:

  • Invalid JSON in Data (JSON): Ensure the input is valid JSON. Malformed JSON will cause the node to fail.
  • Missing required fields: Some fields may be required by Directus (e.g., name). Check the Directus Role Object documentation.
  • Insufficient permissions: The API credentials used must have permission to create roles; otherwise, you may receive authorization errors.
  • Error output: If "Continue On Fail" is enabled, errors will appear in the output under the error key.

Example error output:

{
  "error": "Request failed with status code 403"
}

Resolution: Check your API credentials and ensure they have the necessary permissions.


Links and References


Discussion