Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Overview

The Permissions: List operation in this custom n8n node for Directus allows you to retrieve a list of permission objects from your Directus instance. This is useful for automating the management, auditing, or reporting of permissions within your Directus project. For example, you might use this node to:

  • Generate reports on current permissions for compliance.
  • Audit changes to permissions over time.
  • Integrate permission data into other systems or workflows.

You can customize the query with filters, sorting, aggregation, and even export the results as files (CSV, JSON, XML).


Properties

Name Type Meaning
Return All boolean If enabled, returns all permission records; if disabled, limits the number of returned items according to the "Limit" property.
Limit number The maximum number of permission objects to return (only shown if "Return All" is false). Must be between 1 and 100.
Split Into Items boolean If enabled, outputs each permission object as a separate item in the workflow. If disabled, returns all results in a single item.
JSON/RAW Parameters boolean If enabled, allows you to specify query parameters as raw JSON instead of using the UI fields.
Query Parameters json Custom query parameters as a flat JSON object (shown only if "JSON/RAW Parameters" is enabled).
Additional Fields collection Extra options to refine the query, such as aggregation, export format, filtering, grouping, metadata, offset, search, sorting, etc.
└ Aggregate collection Aggregation functions (e.g., count, sum, avg) to apply to the result set.
└ Binary Property for Export Data string Name of the binary property to which exported file data will be attached.
└ Deep (JSON) json Allows setting nested query parameters for related datasets.
└ Export options Exports the API response to a file in CSV, JSON, or XML format.
└ Fields string Specifies which fields to include in the response.
└ File Name for Export Data string File name (without extension) for exported data.
└ Filter (JSON) json Filters the results based on specified conditions.
└ Group By string Groups results by one or more fields for aggregation purposes.
└ Meta string Specifies what metadata to include in the response.
└ Offset number Number of items to skip before starting to collect the result set.
└ Search string Searches for items containing the given query in any field.
└ Sort string Specifies how to sort the returned items (CSV of fields, supports ASC/DESC/random).

Output

  • json:

    • If "Split Into Items" is enabled, each output item contains a single permission object in its json property.
    • If not, the json property contains an array or object with all retrieved permissions.
    • If an error occurs and "Continue On Fail" is enabled, the output will contain { "error": "<error message>" }.
  • binary (optional):

    • If "Export" is used, the exported file (CSV, JSON, or XML) is attached to the output under the specified binary property name (default: data).
    • The binary data represents the exported permission data in the chosen format.

Dependencies

  • Directus API: Requires access to a Directus instance.
  • API Credentials: You must configure the directusApi credentials in n8n for authentication.

Troubleshooting

Common Issues:

  • Invalid Credentials: If the Directus API credentials are missing or incorrect, the node will fail to connect.
  • Malformed JSON: When using JSON/RAW parameters, ensure that your JSON is valid. Invalid JSON will cause parsing errors.
  • Permission Denied: If the authenticated user does not have permission to list permissions, the API will return an error.
  • Large Result Sets: Not enabling "Return All" or setting a high "Limit" may result in incomplete data or performance issues.

Error Messages:

  • "error": "Unexpected token ...": Indicates malformed JSON input.
  • "error": "Request failed with status code 401": Authentication issue—check your credentials.
  • "error": "Request failed with status code 403": Insufficient permissions for the requested operation.
  • "error": "Request failed with status code 400": Likely due to invalid query parameters or filters.

How to Resolve:

  • Double-check your credentials and permissions in Directus.
  • Validate all JSON inputs using a linter or online tool.
  • Adjust "Limit" or use pagination if retrieving large datasets.

Links and References

Discussion