Directus icon

Directus

Consume Directus API

Overview

The Directus n8n node, when configured with the Item resource and the Delete operation, allows you to delete a specific item (record) from a specified collection in your Directus instance. This is useful for automating data cleanup, removing outdated or incorrect records, or integrating Directus data management into broader workflows.

Practical scenarios:

  • Automatically remove items from a collection after processing.
  • Clean up test or temporary data as part of a CI/CD pipeline.
  • Integrate with other systems to delete records in Directus based on external triggers.

Properties

Name Type Meaning
ID String Unique ID of the item (record) to be deleted from the collection.
Collection Options The unique name of the parent collection containing the target item.

Output

  • The output will be an object in the json field.
  • The structure of this object depends on the response from the Directus API after attempting to delete the item. Typically, it may be an empty object {} or contain metadata about the deletion.
  • If an error occurs and "Continue On Fail" is enabled, the output will include an error property with the error message.

Example output:

{
  "json": {}
}

or, on error:

{
  "json": {
    "error": "Item not found"
  }
}

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure the node with valid Directus API credentials (directusApi).
  • n8n Configuration: No special environment variables are required beyond standard credential setup.

Troubleshooting

Common issues:

  • Invalid ID or Collection: If the provided ID does not exist in the specified collection, the node will return an error such as "Item not found".
  • Insufficient Permissions: The API credentials used must have permission to delete items in the specified collection; otherwise, you may receive a "Forbidden" or "Unauthorized" error.
  • Incorrect Collection Name: Ensure the collection name matches exactly (case-sensitive) with what exists in Directus.

Error messages and resolutions:

  • "Item not found": Check that both the Collection and ID are correct and that the item exists.
  • "Forbidden" or "Unauthorized": Verify that the API credentials have sufficient permissions.
  • "Collection not found": Double-check the collection name for typos or case mismatches.

Links and References

Discussion