Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Folders → List

AI-generated

Overview

The Folders: List operation in this n8n node allows you to retrieve a list of folders from a Directus instance. This is useful for automating workflows that need to access, filter, or process folder metadata stored in Directus, such as organizing digital assets, managing file hierarchies, or generating reports on folder structures.

Practical examples:

  • Fetch all folders to display them in a dashboard.
  • Retrieve only a subset of folders matching certain criteria (e.g., by name, parent, or custom filters).
  • Export the list of folders as CSV, JSON, or XML for reporting or backup purposes.
  • Process each folder individually in subsequent workflow steps.

Properties

Name Type Meaning
Return All boolean If enabled, returns all available folders. If disabled, limits the number of returned folders according to the "Limit" property.
Limit number The maximum number of folders to return (only shown if "Return All" is false). Must be between 1 and 100.
Split Into Items boolean If enabled, outputs each folder as a separate item; otherwise, returns an array of folders 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 (only visible if "JSON/RAW Parameters" is enabled).
Additional Fields collection Extra options to refine the query, including aggregation, export, filtering, sorting, and more (see below for sub-options).

Additional Fields sub-options:

  • Aggregate: Apply aggregation functions (count, sum, avg, min, max, etc.) to folder data.
  • Binary Property for Export Data: Name of the binary property to store exported file data.
  • Deep (JSON): Set nested query parameters for related datasets.
  • Export: Export the API response as a file (CSV, JSON, or 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 folders based on conditions (as JSON).
  • Group By: Group results by specified fields for aggregation.
  • Meta: Specify what metadata to include in the response.
  • Offset: Number of items to skip (for pagination).
  • Search: Search string to filter folders by content.
  • Sort: Sorting order for the returned folders.

Output

  • json:

    • If "Split Into Items" is enabled, each output item contains a single folder's data as a JSON object.
    • If not, the output is a single item with a json field containing an array of folder objects.
    • The structure of each folder object depends on the fields requested but typically includes properties like id, name, parent, and other folder metadata.
  • binary (optional):

    • If "Export" is used, the exported file (CSV, JSON, or XML) is attached as binary data under the specified property name.

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure Directus API credentials in n8n (via the directusApi credential type).

Troubleshooting

Common issues:

  • Authentication errors: Ensure your Directus API credentials are correct and have permission to list folders.
  • Invalid JSON: When using "Query Parameters" or "Filter (JSON)", ensure the input is valid JSON. Malformed JSON will cause errors.
  • Limit exceeded: If "Limit" is set above 100, the node may throw a validation error.
  • Empty results: If filters are too restrictive, no folders may be returned.
  • Export errors: If exporting, ensure the "Binary Property for Export Data" and "File Name for Export Data" are set correctly.

Error messages:

  • "Unexpected token...": Indicates invalid JSON in one of the JSON fields.
  • "Request failed with status code 401/403": Authentication or permission issue.
  • "limit must be between 1 and 100": Adjust the "Limit" value.

Links and References

Discussion