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
Roles → List
AI-generatedOverview
The Directus (DrWade) n8n node for the resource Roles with the operation List allows you to retrieve a list of roles from your Directus instance. This is useful for automating workflows that need to access, filter, or process user role information—such as synchronizing permissions, auditing access levels, or integrating role data into other systems.
Practical examples:
- Fetch all roles to display in a dashboard.
- Retrieve a limited set of roles for reporting or further processing.
- Export the list of roles in CSV, JSON, or XML format for compliance or backup purposes.
- Split the result so each role is output as a separate item for downstream processing.
Properties
| Name | Type | Meaning |
|---|---|---|
| Return All | boolean | If enabled, returns all available roles. If disabled, only up to the specified "Limit" number of roles will be returned. |
| Limit | number | The maximum number of roles to return when "Return All" is disabled. Must be between 1 and 100. |
| Split Into Items | boolean | If enabled, outputs each role as a separate item; otherwise, all roles are returned in a single array. |
| JSON/RAW Parameters | boolean | If enabled, allows you to specify query parameters as raw JSON instead of using the UI fields. |
| Query Parameters | json | When "JSON/RAW Parameters" is enabled, this field lets you provide additional query parameters as a flat JSON object. |
| Additional Fields | collection | Extra options to customize the request, such as aggregation, export settings, filtering, sorting, grouping, and more. See below for details on its sub-properties. |
Additional Fields sub-properties:
- Aggregate: Apply aggregation functions (e.g., count, sum, avg) to fields.
- Binary Property for Export Data: Name of the binary property to store exported file data.
- Deep (JSON): Set nested query parameters for relational datasets.
- Export: Choose to export the API response as a file (CSV, JSON, XML).
- Fields: Specify which fields to include in the response.
- File Name for Export Data: File name (without extension) for exported data.
- Filter (JSON): Filter roles by specific conditions.
- Group By: Group results by one or more fields.
- Meta: Specify metadata to include in the response.
- Offset: Skip a number of items before returning results.
- Search: Search for roles containing a specific string.
- Sort: Sort the returned roles by specified fields.
Output
json:
- If "Split Into Items" is enabled, each output item contains a single role object in the
jsonfield. - If not, the
jsonfield contains an array of role objects. - Each role object typically includes properties such as
id,name,description, and any other fields defined in your Directus roles schema.
- If "Split Into Items" is enabled, each output item contains a single role object in the
binary (optional):
- If "Export" is used, the output may also include a
binaryfield containing the exported file (CSV, JSON, or XML), stored under the property name specified in "Binary Property for Export Data".
- If "Export" is used, the output may also include a
Example output (JSON, simplified):
[
{
"json": {
"id": "1",
"name": "Administrator",
"description": "Full access"
}
},
{
"json": {
"id": "2",
"name": "Editor",
"description": "Can edit content"
}
}
]
Or, if not split:
[
{
"json": [
{ "id": "1", "name": "Administrator", "description": "Full access" },
{ "id": "2", "name": "Editor", "description": "Can edit content" }
]
}
]
If exporting:
[
{
"json": [ ... ],
"binary": {
"data": { /* file buffer and metadata */ }
}
}
]
Dependencies
- Directus API: Requires a valid Directus instance accessible via HTTP(S).
- API Credentials: You must configure the
directusApicredentials in n8n with appropriate permissions to read roles. - n8n Environment: No special environment variables required beyond standard n8n setup.
Troubleshooting
Common issues:
- Authentication errors: Ensure your Directus API credentials are correct and have permission to access roles.
- Invalid JSON: If using "JSON/RAW Parameters" or filters, ensure your JSON syntax is valid.
- Empty results: Check your filters, search, or limit settings; you may be excluding all roles unintentionally.
- Export errors: If exporting, verify the "Binary Property for Export Data" and "File Name for Export Data" fields are set correctly.
Error messages:
"error": "Request failed with status code 401": Invalid credentials or insufficient permissions."error": "Unexpected token ..." or "JSON parse error": Malformed JSON in parameters."error": "limit must be between 1 and 100": The "Limit" value is outside the allowed range.