Directus icon

Directus

Consume Directus API

Overview

This node interacts with the Directus API to manage data items within custom collections. Specifically, the Delete Multiple operation under the Items resource allows users to delete multiple items at once from a specified collection by providing an array of item primary keys.

This operation is beneficial when you need to bulk-remove records from a Directus-managed database efficiently, such as cleaning up outdated entries, removing test data, or batch-deleting user-generated content.

Example use case:
You have a collection named "articles" and want to delete several articles identified by their IDs [15, 16, 21]. Using this node operation, you specify the collection and provide the list of IDs to remove all those articles in one API call.

Properties

Name Meaning
Collection Unique name of the parent collection from which items will be deleted.
Data (JSON) An array of item primary keys (IDs) specifying which items to delete from the collection.

Output

The output JSON contains the response from the Directus API after attempting to delete the specified items. Typically, this includes confirmation of deletion or details about any errors encountered.

The structure generally looks like:

{
  "data": { /* API response data about the deletion result */ }
}

No binary data output is produced by this operation.

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 for item management.
  • Proper permissions on the Directus side are necessary to perform deletions on the specified collection.

Troubleshooting

  • Invalid Collection Name: If the collection name does not exist or is misspelled, the API will return an error. Verify the collection name matches exactly the one defined in Directus.
  • Invalid Item Keys: Providing invalid or non-existent item IDs will cause the API to fail or ignore those entries. Ensure the IDs are correct and exist in the collection.
  • Permission Denied: Lack of sufficient permissions to delete items in the collection will result in authorization errors. Confirm that the API key has delete rights.
  • Malformed JSON Data: The Data (JSON) property must be a valid JSON array of IDs. Invalid JSON syntax will cause parsing errors.
  • API Connectivity Issues: Network problems or incorrect API credentials will prevent successful requests. Check connectivity and credential configuration.

If the node throws errors, enabling "Continue On Fail" can help process other items while logging errors for failed ones.

Links and References

Discussion