Directus icon

Directus

Consume Directus API

Overview

The Item → Delete Multiple operation in this custom n8n node for Directus allows you to delete multiple items from a specified collection in your Directus instance in a single API call. This is particularly useful when you need to perform bulk deletions, such as cleaning up test data, removing outdated records, or managing large datasets efficiently.

Practical examples:

  • Deleting a batch of articles by their IDs from an "articles" collection.
  • Removing multiple user records based on a list of primary keys.
  • Cleaning up obsolete entries in any custom collection.

Properties

Name Type Meaning
Collection options Unique name of the parent collection from which items will be deleted. (Required)
Data (JSON) json An array of item primary keys (IDs) to delete. Example: [15, 16, 21] (Required)

Output

  • The output is a JSON object containing the result of the deletion operation as returned by the Directus API.
  • The structure typically reflects the API's response after attempting to delete the specified items. For successful operations, it may include details about the deleted items or a status confirmation.
  • If an error occurs and "Continue On Fail" is enabled, the output will contain an error field with the error message.

Example output:

{
  "json": {
    // Directus API response, e.g., { "data": [...] } or { "success": true }
  }
}

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 Collection Name: If the collection does not exist, the API will return an error.
  • Malformed Data Input: If the "Data (JSON)" property is not a valid JSON array of primary keys, the operation will fail.
  • Permission Denied: The API credentials used must have permission to delete items in the specified collection.
  • Partial Deletion: If some IDs do not exist, the API may return partial success or an error depending on Directus configuration.

Error messages and resolutions:

  • "Collection not found": Check that the collection name is correct and exists in Directus.
  • "Invalid primary key(s)": Ensure the "Data (JSON)" input is a valid array of existing item IDs.
  • "Unauthorized" or "Forbidden": Verify that your API credentials have sufficient permissions.

Links and References


This summary provides a clear understanding of how to use the "Delete Multiple" operation for items in Directus via n8n, including its inputs, outputs, dependencies, and troubleshooting tips.

Discussion