Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Overview

The Files → Delete Multiple operation in this n8n node allows you to delete multiple files from a Directus instance in a single API call. This is particularly useful for workflows where you need to clean up or remove several files at once, such as after batch processing, data migration, or when implementing bulk file management features.

Practical examples:

  • Deleting all temporary files uploaded during a workflow.
  • Removing obsolete or duplicate files based on a list of IDs.
  • Automating cleanup tasks after importing or exporting data.

Properties

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

Output

  • The output will be a JSON object reflecting the response from the Directus API after attempting to delete the specified files.
  • The structure typically includes a data field with details about the deletion result, but may also include an error field if something went wrong.
  • Example output:
    {
      "data": {
        // Details about deleted files, e.g., count or list of deleted IDs
      }
    }
    
  • If an error occurs and "Continue On Fail" is enabled, the output will contain:
    {
      "error": "Error message here"
    }
    

Dependencies

  • Directus API: You must have access to a running Directus instance.
  • API Credentials: The node requires valid Directus API credentials (directusApi) configured in n8n.

Troubleshooting

Common issues:

  • Invalid or missing keys: If the Keys (JSON) property is not a valid JSON array of file IDs, the node will throw a parsing error.
  • Permission errors: If the API credentials do not have permission to delete files, the API will return an authorization error.
  • Non-existent IDs: If any provided file ID does not exist, the API may return an error or ignore those IDs, depending on Directus configuration.

Error messages and resolutions:

  • "Unexpected token ...": The Keys (JSON) input is not valid JSON. Ensure you provide a properly formatted array, e.g., ["id1", "id2"].
  • "You are not authorized to perform this action": Check your Directus user permissions and API credentials.
  • "File(s) not found": Double-check that all provided IDs correspond to existing files in Directus.

Links and References

Discussion