Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Overview

The Fields → Delete operation in this custom n8n node allows you to delete a specific field from a collection in a Directus instance. This is useful for managing your data model by removing fields that are no longer needed or were created by mistake.

Common scenarios:

  • Cleaning up unused or deprecated fields in a collection.
  • Automating schema changes as part of a deployment or migration workflow.
  • Ensuring collections only contain relevant and necessary fields.

Practical example:
Suppose you have a collection called articles with a field named old_tag. If you want to remove the old_tag field from the articles collection, you would use this operation.


Properties

Name Type Meaning
Field options Unique name of the field to delete. Field name is unique within the selected collection.
Collection options The name of the collection from which the field will be deleted.

Output

  • The output will be a JSON object containing the response from the Directus API after attempting to delete the specified field.
  • The structure of the output typically reflects the Directus API's response for a successful or failed deletion. For a successful deletion, it may return an empty object or a confirmation message. For errors, it will include error details.

Example output (success):

{
  "json": {}
}

Example output (error, if continueOnFail is enabled):

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

Dependencies

  • Directus API: You must have access to a running Directus instance.
  • API Credentials: The node requires valid Directus API credentials (directusApi) configured in n8n.

Troubleshooting

Common issues:

  • Invalid Collection or Field Name: If the specified collection or field does not exist, the operation will fail.
  • Insufficient Permissions: The API user must have permission to modify the collection schema.
  • Field in Use: Attempting to delete a field that is referenced elsewhere (e.g., in relationships) may result in an error.

Error messages and resolutions:

  • "Field not found": Double-check the field and collection names.
  • "Permission denied": Ensure your API credentials have sufficient rights.
  • "Cannot delete field in use": Remove dependencies before deleting the field.

Links and References

Discussion