Directus icon

Directus

Consume Directus API

Overview

This node interacts with the Directus API to manage relations between collections in a Directus-managed database. Specifically, the "Relations" resource with the "Delete" operation allows users to delete a relation field from a specified collection.

Use cases include:

  • Removing an existing relational link between two collections.
  • Cleaning up or restructuring your Directus data model by deleting obsolete or incorrect relations.
  • Automating schema changes in Directus via workflows.

For example, if you have a collection "books" with a relational field "author" linking to an "authors" collection, this node can delete that "author" relation field from the "books" collection.

Properties

Name Meaning
Collection Unique name of the parent collection from which the relation field will be deleted.
Field Name of the field holding the related primary key (the relation field) to be deleted.

The "Collection" property dynamically loads available collections from Directus. The "Field" property depends on the selected collection and lists relational fields within it.

Output

The output is a JSON object representing the response from the Directus API after attempting to delete the specified relation. Typically, this will confirm successful deletion or provide error details.

Example output JSON structure:

{
  "data": {
    // Details about the deleted relation or confirmation message
  }
}

No binary data output is involved in 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 relations management.
  • No additional external dependencies are required beyond the Directus API access.

Troubleshooting

  • Common issues:

    • Specifying a non-existent collection or field will result in errors.
    • Insufficient permissions in Directus API credentials may cause authorization failures.
    • Network connectivity problems to the Directus server will prevent API calls.
  • Error messages:

    • 404 Not Found: The specified collection or relation field does not exist.
    • 401 Unauthorized: The API key or authentication token is invalid or lacks permission.
    • 400 Bad Request: Invalid parameters sent to the API, e.g., missing required fields.
  • Resolutions:

    • Verify the collection and field names are correct and exist in Directus.
    • Ensure the API credentials used have sufficient rights to modify relations.
    • Check network connectivity and Directus server availability.

Links and References

Discussion