Directus icon

Directus

Consume Directus API

Overview

The Directus - Roles: Create operation in this n8n node allows you to create a new role within your Directus instance. This is useful for automating the management of user roles, such as setting up permissions and access levels for different types of users (e.g., admins, editors, viewers, interns). For example, you might use this node in an onboarding workflow to automatically create a custom role when a new department is added to your organization.

Properties

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

Output

  • The output will be a single item with a json field containing the details of the newly created role as returned by the Directus API.
  • The structure of the output JSON will match the Directus Role Object, typically including fields such as:
    • id
    • name
    • icon
    • description
    • admin_access
    • app_access
    • ...and any other properties set or returned by Directus.

Example output:

{
  "id": "12345",
  "name": "Interns",
  "icon": "verified_user",
  "description": null,
  "admin_access": false,
  "app_access": true,
  // ...other role properties
}

Dependencies

  • Directus API: You must have a running Directus instance accessible from n8n.
  • API Credentials: The node requires valid Directus API credentials configured in n8n under the name directusApi.

Troubleshooting

  • Invalid JSON in Data (JSON): If the input is not valid JSON, the node will throw a parsing error. Ensure your JSON is correctly formatted.
  • Missing Required Fields: If required fields for a role are missing (such as name), the Directus API may return an error. Refer to the Directus Role Object documentation for required fields.
  • Permission Denied: If the API credentials do not have permission to create roles, you will receive an authorization error. Make sure your API user has sufficient privileges.
  • API Connection Issues: Network or authentication errors will result in connection failures. Double-check your Directus URL and credentials.

Links and References

Discussion