Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Overview

The Folders: Create operation in this n8n node allows you to create a new folder within your Directus instance. This is useful for organizing files and assets into logical groups, supporting nested folder structures by specifying a parent folder. Typical use cases include:

  • Structuring digital assets (images, documents) for projects or clients.
  • Automating the creation of folders as part of onboarding workflows.
  • Creating nested folder hierarchies programmatically.

Example:
Automatically create a "Project X" folder with subfolders like "Designs" and "Contracts" when a new project is started.


Properties

Name Type Meaning
Name String The name of the folder to be created.
JSON/RAW Parameters Boolean If enabled, allows you to provide all 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 Optional extra fields for the folder. Includes:
  Parent String Unique identifier of the parent folder (for creating nested folders).

Output

  • The output will be a single item with a json field containing the details of the newly created folder as returned by the Directus API.
  • The structure typically includes fields such as:
    • id: Unique identifier of the folder.
    • name: Name of the folder.
    • parent: Parent folder ID (if specified).
    • Other metadata as provided by Directus.

Example output:

{
  "id": "abc123",
  "name": "Nature",
  "parent": "xyz789"
}
  • No binary data is produced by this operation.

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 "Name" is not provided, the request will fail.
  • Invalid Parent ID: Specifying a non-existent parent folder ID will result in an error from Directus.
  • Malformed JSON: When using "JSON/RAW Parameters", ensure the JSON is valid.

Error Messages:

  • "error": "Request failed with status code 400": Usually indicates missing or invalid input data.
  • "error": "Parent folder not found": The specified parent does not exist.

How to resolve:

  • Double-check required fields.
  • Validate any IDs used for parent folders.
  • Use a JSON validator when entering raw JSON.

Links and References

Discussion