Directus icon

Directus

Consume Directus API

Overview

This node integrates with the Directus API to manage files and other resources. Specifically, for the Files resource with the Delete Multiple operation, it allows users to delete multiple files in a single request by providing an array of file primary keys.

Common scenarios where this node is beneficial include:

  • Bulk cleanup of unused or obsolete files stored in Directus.
  • Automating file management workflows where multiple files need to be removed based on certain criteria.
  • Integrating with other systems that trigger batch deletions of media or document files.

Practical example:

  • A user has a list of file IDs representing outdated images in their Directus instance. Using this node, they can input the array of these IDs and delete all those files at once, streamlining maintenance tasks.

Properties

Name Meaning
Keys (JSON) An array of primary keys (IDs) of the files to delete. Example: ["id1", "id2", "id3"].

Output

The output JSON contains the response from the Directus API after attempting to delete the specified files. Typically, this will include information about the deletion result, such as success confirmation or details of any errors encountered.

No binary data is output by this operation.

Example output JSON structure (conceptual):

{
  "data": {
    // Details about deleted files or operation status
  }
}

Dependencies

  • Requires a valid connection to a Directus instance via an API key credential configured in n8n.
  • The node uses the Directus REST API endpoints to perform operations.
  • Proper permissions are required on the Directus side to delete files.

Troubleshooting

  • Invalid Keys Format: If the "Keys (JSON)" property is not a valid JSON array or contains invalid IDs, the API call will fail. Ensure the input is a correctly formatted JSON array of strings or numbers representing file IDs.

  • Permission Denied: If the API credentials do not have sufficient rights to delete files, the operation will return an authorization error. Verify the API key's permissions in Directus.

  • File Not Found: If one or more provided keys do not correspond to existing files, the API may return an error or partial success. Confirm that all file IDs exist before attempting deletion.

  • Network or API Errors: General connectivity issues or server errors will cause the node to throw errors. Check network connectivity and Directus server status.

  • To handle errors gracefully, enable the "Continue On Fail" option in the node settings to allow processing of subsequent items even if some deletions fail.

Links and References

Discussion