Directus icon

Directus

Consume Directus API

Overview

The Directus - Roles: Get operation node retrieves detailed information about a specific role from a Directus instance using its unique ID. This is useful in scenarios where you need to fetch and utilize metadata or permissions associated with a particular role, such as automating user management workflows, auditing access levels, or integrating role-based logic into your n8n automation.

Practical examples:

  • Fetching role details to display or use in subsequent workflow steps.
  • Validating if a user has the correct role before performing actions.
  • Auditing or reporting on roles within your Directus project.

Properties

Name Type Meaning
ID String Primary key of the role to retrieve.

Output

The output will be a single item in the json field containing all available properties of the requested role. The structure depends on your Directus setup but typically includes fields like:

{
  "id": "c86c2761-65d3-43c3-897f-6f74ad6a5bd7",
  "name": "Administrator",
  "description": "Full access to all resources.",
  "admin_access": true,
  "app_access": true,
  "icon": "user-shield",
  "enforce_tfa": false,
  "users": [...],
  ...
}
  • All properties returned are directly from the Directus API for the specified role.
  • If an error occurs and "Continue On Fail" is enabled, the output will contain an error property with the error message.

Dependencies

  • Directus API: Requires a valid Directus instance accessible via HTTP(S).
  • API Credentials: You must configure the directusApi credentials in n8n for authentication.

Troubleshooting

Common issues:

  • Invalid Role ID: If the provided ID does not exist, you'll receive an error message indicating that the role was not found.
  • Authentication Errors: Invalid or missing API credentials will result in authentication errors.
  • Network Issues: Connectivity problems between n8n and the Directus server can cause request failures.

Error messages and resolutions:

  • "Role not found": Check that the ID is correct and exists in your Directus instance.
  • "401 Unauthorized": Ensure your API credentials are set up correctly in n8n.
  • "Network Error": Verify network connectivity and the Directus server URL.

Links and References

Discussion