Directus icon

Directus

Consume Directus API

Overview

The File → Update Multiple operation in this n8n node allows you to update multiple files at once in a Directus instance. This is particularly useful when you need to apply the same changes (such as updating metadata, tags, or other file properties) to several files simultaneously, rather than updating each file individually.

Common scenarios:

  • Bulk-tagging files for easier organization.
  • Updating custom metadata fields across many files.
  • Changing access permissions or other attributes for a group of files.

Practical example:
Suppose you have uploaded 100 images and want to add the tag "cities" to all of them. Instead of updating each file one by one, you can use this operation to update all relevant files in a single request.


Properties

Name Type Meaning
Update Data (JSON) json JSON object containing:
- keys: Array of file IDs (primary keys) to update.
- data: Object with the file properties to update (see Directus file object docs).

Output

  • The output will be an array of objects under the json field.
  • Each object represents the updated file(s) as returned by the Directus API.
  • The structure of each object matches the Directus file object, including fields such as id, filename_download, title, type, tags, etc.

Example output:

[
  {
    "json": {
      "id": "b6123925-2fc0-4a30-9d86-863eafc0a6e7",
      "tags": ["cities"],
      // ...other file properties
    }
  },
  {
    "json": {
      "id": "d17c10aa-0bad-4864-9296-84f522c753e5",
      "tags": ["cities"],
      // ...other file properties
    }
  }
]

Dependencies

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

Troubleshooting

Common issues:

  • Invalid or missing file IDs: If any ID in the keys array does not exist, the API may return an error.
  • Malformed JSON: Ensure the Update Data (JSON) property is valid JSON and follows the required structure.
  • Insufficient permissions: The API credentials used must have permission to update files in Directus.
  • Error handling: If an error occurs and "Continue On Fail" is enabled, the error message will appear in the output under an error key.

Common error messages:

  • "Cannot read property 'data' of undefined": Likely due to an invalid response from the API, possibly caused by incorrect input data.
  • "Request failed with status code 403": Indicates insufficient permissions.
  • "Invalid JSON": The input for Update Data (JSON) is not properly formatted.

Links and References

Discussion