Directus icon

Directus

Consume Directus API

Overview

The Directus n8n node's "Folder" resource with the "Update Multiple" operation allows you to update multiple folder records in your Directus instance at once. This is particularly useful for batch operations, such as moving several folders under a new parent, updating metadata, or changing properties of many folders simultaneously.

Practical scenarios:

  • Moving a group of folders to a new parent directory.
  • Updating access permissions or metadata for multiple folders in one go.
  • Bulk renaming or reorganizing folder structures.

Example:
You have several folders that need to be moved under a new parent folder. Instead of updating each folder individually, you can use this operation to update all relevant folders in a single request.


Properties

Name Type Meaning
Data (JSON) json A JSON object specifying which folders to update (keys) and the data to apply (data). See below.

Details for "Data (JSON)":

  • keys: An array of folder IDs to update.
  • data: An object containing the fields and values to update for those folders.

Example value:

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

Output

  • The output will be an array of objects, each in the json field, representing the updated folder(s).
  • The structure of each object matches the Directus Folder Object, typically including fields like:
    • id
    • name
    • parent
    • created_at
    • updated_at
    • ...and any other folder properties.

Example output:

{
  "id": "fac21847-d5ce-4e4b-a288-9abafbdfbc87",
  "name": "My Folder",
  "parent": "d97c2e0e-293d-4eb5-9e1c-27d3460ad29d",
  "created_at": "2023-01-01T12:00:00Z",
  "updated_at": "2024-06-01T10:00:00Z"
}

Dependencies

  • Directus API: You must have a running Directus instance accessible from n8n.
  • API Credentials: The node requires valid Directus API credentials configured in n8n under the name directusApi.

Troubleshooting

Common issues:

  • Invalid folder IDs: If any ID in keys does not exist, the operation may fail or only partially succeed.
  • Insufficient permissions: The API user must have permission to update the specified folders.
  • Malformed JSON: Ensure the "Data (JSON)" property is valid JSON; otherwise, parsing errors will occur.

Error messages and resolutions:

  • "Cannot read property 'keys' of undefined": Check that your JSON input includes both keys and data.
  • "Request failed with status code 403": Your API credentials lack sufficient permissions.
  • "Unexpected token ... in JSON": There is a syntax error in your JSON input; validate it before submitting.

Links and References

Discussion