Directus icon

Directus

Consume Directus API

Overview

The Directus node for n8n, when configured with the Resource: Field and Operation: Update, allows you to update an existing field's configuration within a specified collection in your Directus instance. This is useful for programmatically modifying metadata, schema, or type of fields without manual intervention via the Directus admin interface.

Common scenarios include:

  • Changing the data type of a field (e.g., from integer to string).
  • Updating the schema or meta information of a field.
  • Adjusting field options as part of automated migrations or DevOps workflows.

Practical example:
You have a "status" field in your "articles" collection that needs to be changed from a string to an integer type, or you want to update its validation rules or meta description.


Properties

Name Type Meaning
Field options Unique name of the field within the selected collection.
Collection options The name of the collection containing the field to update.
JSON/RAW Parameters boolean If enabled, body parameters are provided as raw JSON; otherwise, use the UI fields.
Body Parameters json (Shown if JSON/RAW Parameters is true) Raw JSON object specifying all properties to update.
Update Fields collection (Shown if JSON/RAW Parameters is false) Key-value pairs for updating specific field settings.
└ Meta (JSON) json Optional meta information for the field.
└ Schema (JSON) json Optional schema definition for the field.
└ Type options Data type for the field (e.g., integer, string, boolean, etc.).

Output

  • The output is a single json object representing the updated field as returned by the Directus API.
  • The structure will match the Directus field object, typically including keys such as:
    • field: The field name.
    • type: The data type.
    • meta: Any meta information.
    • schema: Schema details.
    • Other field configuration properties depending on what was updated.

Example output:

{
  "field": "status",
  "type": "integer",
  "meta": { "interface": "input", "note": "Status as integer" },
  "schema": { "default_value": 0 }
}
  • Binary data: This operation does not produce binary output.

Dependencies

  • External Service: Requires access to a running Directus instance.
  • Authentication: Needs valid Directus API credentials configured in n8n (directusApi credential).
  • Environment: No special environment variables required beyond standard n8n and Directus setup.

Troubleshooting

Common issues:

  • Invalid field or collection name: Ensure both exist in your Directus instance.
  • Insufficient permissions: The API user must have permission to modify fields in the target collection.
  • Malformed JSON: When using "JSON/RAW Parameters," ensure the JSON is valid.
  • Type conflicts: Changing a field's type may fail if existing data cannot be converted.

Error messages:

  • "Field not found": The specified field does not exist in the collection.
  • "Collection not found": The specified collection does not exist.
  • "Invalid payload": The body parameters are malformed or missing required properties.
  • "Permission denied": The API key/user lacks rights to update fields.

Resolution tips:

  • Double-check field and collection names.
  • Validate your JSON before submitting.
  • Review Directus API documentation for field update constraints.
  • Check user permissions in Directus.

Links and References

Discussion