Actions109
- Activity Actions
- Assets Actions
- Authentication Actions
- Collections Actions
- Extensions Actions
- Fields Actions
- Files Actions
- Folders Actions
- Items Actions
- Permissions Actions
- Presets Actions
- Relations Actions
- Revisions Actions
- Roles Actions
- Settings Actions
- Users Actions
- Utilities Actions
- Webhooks Actions
Overview
This node integrates with the Directus API to manage "Roles" resources, specifically supporting the "List" operation. It allows users to retrieve a list of roles defined in a Directus instance, which is useful for workflows that need to handle user permissions, role-based access control, or audit role configurations.
Common scenarios include:
- Fetching all roles to display or process them in an automation.
- Filtering or limiting the number of roles retrieved for performance or pagination.
- Exporting role data in various formats (JSON, CSV, XML) for reporting or backup.
- Splitting the returned array of roles into individual items for further processing downstream.
Practical example:
- An automation that synchronizes roles from Directus to another system by listing all roles and iterating over each one.
- Generating a CSV export of all roles for compliance audits.
Properties
| Name | Meaning |
|---|---|
| Return All | Boolean flag indicating whether to return all roles or limit the number of results. |
| Limit | Number specifying the maximum number of roles to return when "Return All" is false. Valid range: 1 to 100. |
| Split Into Items | Boolean flag to output each role as a separate item instead of a single array. |
| JSON/RAW Parameters | Boolean flag to choose between entering query parameters via UI fields or as raw JSON. |
| Query Parameters | JSON object representing query parameters to filter or modify the request when "JSON/RAW Parameters" is true. |
| Additional Fields | Collection of optional fields to customize the request, including: - Aggregate functions (count, sum, average, min, max, etc.) on specific fields. - Binary property name for export data. - Deep JSON for nested relational queries. - Export format (json, csv, xml). - Fields to return. - File name for export. - Filter conditions. - Group By field. - Metadata to return. - Offset for pagination. - Search query. - Sort order. |
Output
The node outputs the retrieved roles data in the json field of each item. The structure corresponds directly to the response from the Directus API's roles endpoint, typically an array of role objects or a single role object depending on the request.
If the "Split Into Items" option is enabled, each role is output as a separate item; otherwise, all roles are output as a single item containing an array.
If an export format is selected (JSON, CSV, XML), the node also outputs the data as binary under a specified binary property name (default "data"), allowing the data to be saved or passed as a file in subsequent workflow steps.
Dependencies
- Requires a valid connection to a Directus instance via an API key credential configured in n8n.
- The node uses the Directus REST API endpoints related to roles (
GET /rolesandGET /roles/{id}). - No additional external dependencies beyond the Directus API and n8n environment.
Troubleshooting
- Authentication errors: Ensure the API key credential is correctly configured and has sufficient permissions to read roles.
- Invalid JSON in Query Parameters: When using JSON/RAW parameters, ensure the JSON syntax is correct to avoid parsing errors.
- Limit out of range: The "Limit" property must be between 1 and 100; values outside this range may cause API errors.
- Empty results: If no roles are returned, verify that roles exist in the Directus instance and that filters/search parameters are not overly restrictive.
- Export issues: When exporting data, ensure the file name does not contain invalid characters and the chosen format matches the expected content type.
Links and References
- Directus Roles API Documentation
- Directus Official Website
- n8n Documentation on HTTP Request Nodes (for understanding API calls)
This summary covers the "Roles" resource with the "List" operation based on the provided source code and properties.