Directus (denkhaus) icon

Directus (denkhaus)

Consume Directus API

Overview

This n8n node allows you to create a new field in a specified collection within a Directus instance (Resource: Field, Operation: Create). It is useful for dynamically extending your data model by adding custom fields to collections without leaving your workflow automation. For example, you might use this node to add a "firstName" string field to an "articles" collection as part of an onboarding or setup process.

Properties

Name Type Meaning
Name String The name of the field to be created (e.g., "firstName").
Collection Name Options The target collection where the new field will be added (e.g., "articles").
Type Options The data type of the field, following Directus conventions (e.g., Integer, String, DateTime, etc.).
JSON/RAW Parameters Boolean Determines if body parameters are provided as raw JSON or via key-value UI.
Body Parameters JSON Additional field configuration as JSON, used when "JSON/RAW Parameters" is enabled.

Output

The output will contain a json field with the response from the Directus API after creating the field. This typically includes details about the newly created field, such as its name, type, and configuration. The exact structure depends on the Directus API response, but generally resembles:

{
  "id": "field_id",
  "collection": "articles",
  "field": "firstName",
  "type": "string",
  // ...other field properties
}

Dependencies

  • Requires access to a Directus instance.
  • Authentication (API key or credentials) must be configured in n8n for the Directus node.
  • The user must have permission to modify the schema (add fields) in the target Directus collection.

Troubleshooting

  • Permission Denied: If you lack sufficient permissions in Directus, the node may return an error indicating forbidden access. Ensure your API credentials have schema modification rights.
  • Invalid Field Type: Supplying an unsupported or misspelled field type will result in an error from Directus. Use only the types listed in the "Type" property options.
  • Malformed JSON: If "Body Parameters" is used with invalid JSON, the node will throw a parsing error. Double-check your JSON syntax.
  • Collection Not Found: Specifying a non-existent collection will cause the operation to fail. Verify the collection name using the load options dropdown.

Links and References

Discussion