Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Items → Delete Multiple

AI-generated

Overview

The Items → 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 bulk-remove records, such as cleaning up test data, removing outdated entries, or managing large datasets efficiently.

Practical examples:

  • Deleting a batch of articles by their IDs from an "articles" collection.
  • Removing multiple user-submitted forms that are no longer needed.
  • Cleaning up old log entries from a logs collection.

Properties

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

Output

  • The output is a JSON object reflecting the result of the delete operation.
  • The structure typically contains a data field with details about the deletion outcome, but may vary depending on the Directus API response.
  • If an error occurs and "Continue On Fail" is enabled, the output will include an error field with the error message.

Example output:

{
  "data": {
    // Details about deleted items, e.g., count or list of deleted IDs
  }
}

or, on error:

{
  "error": "Error message describing what went wrong"
}

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 (JSON): If the provided array of IDs is not valid JSON, the operation will fail.
  • Permission Denied: The API credentials used must have permission to delete items in the specified collection.
  • Non-existent IDs: If some IDs do not exist, the API may ignore them or return an error, depending on Directus configuration.

Common error messages:

  • "Collection not found": Check the collection name.
  • "Invalid JSON": Ensure the Data (JSON) property is a valid JSON array.
  • "Unauthorized" or "Forbidden": Verify your API credentials and permissions.

Links and References

Discussion