Directus icon

Directus

Consume Directus API

Overview

The Directus n8n node, when configured with the Folder resource and the Create operation, allows you to create a new folder in your Directus instance. This is useful for organizing files and assets within Directus by creating hierarchical or flat folder structures as needed.

Common scenarios:

  • Automating the creation of folders for new projects, clients, or campaigns.
  • Structuring asset storage dynamically based on workflow logic.
  • Integrating with other systems to mirror their folder structure in Directus.

Practical example:
When a new client signs up via a form, an n8n workflow could automatically create a dedicated folder for that client in Directus to store all related files.


Properties

Name Type Meaning
Name String The name of the folder to be created.
JSON/RAW Parameters Boolean If enabled, allows specifying body parameters as raw JSON instead of using UI fields.
Body Parameters JSON (Shown if JSON/RAW Parameters is true) Raw JSON object containing folder properties.
Additional Fields Collection (Shown if JSON/RAW Parameters is false) Optional extra fields for the folder, such as Parent.
└─ Parent String Unique identifier of the parent folder (for nested folders).

Output

  • The output will be a json object representing the newly created folder as returned by the Directus API.
  • Typical fields may include:
    • id: Unique identifier of the folder.
    • name: Name of the folder.
    • parent: ID of the parent folder (if any).
    • Other metadata as provided by Directus.

Example output:

{
  "id": "abc123",
  "name": "Nature",
  "parent": null,
  // ...other Directus folder fields
}

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure the directusApi credentials in n8n for authentication.

Troubleshooting

Common issues:

  • Missing required fields: If the "Name" property is not provided, the node will throw an error.
  • Invalid Parent ID: Providing a non-existent parent folder ID will result in an error from Directus.
  • Authentication errors: Invalid or missing API credentials will prevent folder creation.

Error messages and resolutions:

  • "error": "Request failed with status code 401": Check your Directus API credentials.
  • "error": "Field 'name' is required": Ensure the "Name" field is filled in.
  • "error": "Parent folder not found": Verify the "Parent" field references a valid folder ID.

Links and References


Discussion