Directus icon

Directus

Consume Directus API

Overview

The Roles: Update operation in this n8n node allows you to update an existing role in a Directus instance. This is useful for programmatically modifying the properties of user roles, such as changing permissions, updating the role's icon, or altering other metadata associated with a role.

Common scenarios include:

  • Automating updates to user roles based on business logic.
  • Integrating role management into larger workflows (e.g., when onboarding new teams or restructuring access).
  • Keeping role information synchronized between systems.

Practical example:
If your organization changes its permission structure, you can use this node to update the relevant roles across all environments automatically.


Properties

Name Type Meaning
Data (JSON) json A partial role object. Contains the fields and values to update for the specified role. Example: { "icon": "attractions" }
ID string The primary key (UUID) of the role you want to update. Example: c86c2761-65d3-43c3-897f-6f74ad6a5bd7

Output

  • The output will be a single json object representing the updated role as returned by the Directus API.
  • The structure of the output matches the Directus Role Object, which typically includes fields like:
    • id
    • name
    • icon
    • description
    • admin_access
    • app_access
    • ...and any other fields present in the role object.

Example output:

{
  "id": "c86c2761-65d3-43c3-897f-6f74ad6a5bd7",
  "name": "Editor",
  "icon": "attractions",
  "description": "Can edit content",
  "admin_access": false,
  "app_access": true
}

Dependencies

  • External Service: Requires access to a Directus instance.
  • Authentication: Needs valid Directus API credentials configured in n8n under the name directusApi.
  • Environment: The node must be able to reach the Directus API endpoint.

Troubleshooting

Common issues:

  • Invalid ID: If the provided role ID does not exist, the node will return an error from the Directus API.
  • Malformed JSON: If the Data (JSON) property is not valid JSON, the node will throw a parsing error.
  • Insufficient Permissions: The API credentials used must have permission to update roles; otherwise, you'll receive a permission error.
  • Network Issues: Connectivity problems between n8n and Directus will result in request failures.

Error messages and resolutions:

  • "Role not found": Check that the ID is correct and exists in your Directus instance.
  • "Invalid JSON": Ensure the data field contains properly formatted JSON.
  • "Forbidden" or "Unauthorized": Verify that your API credentials are correct and have sufficient privileges.

Links and References

Discussion