Directus icon

Directus

Consume Directus API

Overview

This node interacts with the Directus API to update multiple folder records in bulk. It sends a PATCH request to the "folders" endpoint with a JSON payload specifying which folders to update and the new data to apply.

Common scenarios for this node include:

  • Bulk updating folder metadata or properties, such as changing the parent folder for multiple folders at once.
  • Organizing folder structures programmatically by moving several folders under a new parent folder.
  • Applying consistent updates across many folders without needing to update each one individually.

For example, you might use this node to move multiple folders into a new parent folder by providing their keys and the new parent ID in the data JSON.

Properties

Name Meaning
Data (JSON) A JSON object containing:
- keys: an array of folder IDs (UUIDs) to update
- data: an object with any folder properties to update (e.g., "parent" to change the parent folder). The structure matches the Directus folder object.

Example value for Data (JSON):

{
  "keys": [
    "fac21847-d5ce-4e4b-a288-9abafbdfbc87",
    "a5bdb793-dd85-4ac9-882a-b42862092983"
  ],
  "data": {
    "parent": "d97c2e0e-293d-4eb5-9e1c-27d3460ad29d"
  }
}

Output

The node outputs an array of JSON objects representing the response from the Directus API after the bulk update operation. Each output item corresponds to the API's response data, typically including information about the updated folders.

The exact structure depends on the Directus API response but generally includes confirmation of the updated folder records.

This node does not output binary data.

Dependencies

  • Requires a valid connection to a Directus instance via an API key credential configured in n8n.
  • The node uses the Directus REST API, specifically the PATCH method on the /folders endpoint.
  • Proper permissions are needed in Directus to perform bulk updates on folders.

Troubleshooting

  • Invalid JSON in Data (JSON): If the JSON provided is malformed, the node will throw a parsing error. Ensure the JSON syntax is correct.
  • Missing or incorrect folder keys: If the keys array is empty or contains invalid folder IDs, the API may return errors or no changes will be made.
  • Insufficient permissions: The API call may fail if the API key lacks permission to update folders.
  • Network or authentication errors: Check that the Directus API credentials are correctly set up and the Directus server is reachable.
  • API response errors: The node throws errors returned by the Directus API; review the error message for details and adjust input accordingly.

To resolve errors:

  • Validate the JSON input carefully.
  • Confirm folder IDs exist in Directus.
  • Verify API credentials and permissions.
  • Review Directus API documentation for error codes.

Links and References

Discussion