Actions100
- Activity Actions
- Asset Actions
- Authentication Actions
- Collection Actions
- Extension Actions
- Field Actions
- File Actions
- Folder Actions
- Item Actions
- Permission Actions
- Preset Actions
- Relation Actions
- Revisions Actions
- Roles Actions
- Settings Actions
- Users Actions
- Utilities Actions
Overview
The Directus n8n node, when configured with the Resource: Folder and Operation: Create Multiple, allows you to create multiple folders in a Directus instance in a single API call. This is particularly useful for batch operations where you need to set up several folder structures at once, such as initializing a new project, migrating data, or organizing assets programmatically.
Practical examples:
- Creating a set of categorized folders (e.g., "Nature", "Cities") for asset management.
- Automating the setup of folder hierarchies during onboarding of new clients or projects.
- Bulk importing folder structures from another system into Directus.
Properties
Name | Type | Meaning |
---|---|---|
Data (JSON) | json | An array of partial folder objects. Each object must include at least the name property. Optionally, you can specify a parent folder ID. |
Output
- The output will be a single item with a
json
field containing the response from the Directus API after creating the folders. - The structure of the
json
field typically matches the Directus folder object(s), which may include properties like:id
: Unique identifier of the foldername
: Name of the folderparent
: Parent folder ID (if specified)- Other metadata fields managed by Directus
Example output:
{
"json": [
{
"id": "123",
"name": "Nature",
"parent": "0fca80c4-d61c-4404-9fd7-6ba86b64154d"
},
{
"id": "124",
"name": "Cities",
"parent": null
}
]
}
- If an error occurs and "Continue On Fail" is enabled, the output will contain an
error
field with the error message.
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. - n8n Configuration: No special environment variables are required beyond standard credential setup.
Troubleshooting
Common issues:
- Invalid JSON in Data (JSON): If the input is not valid JSON, the node will throw a parsing error. Ensure your input is a properly formatted JSON array.
- Missing Required Fields: Each folder object must have a
name
. Omitting this will result in an error from the Directus API. - Permission Errors: The API credentials used must have permission to create folders in Directus.
- Parent Folder Not Found: If you specify a
parent
ID that does not exist, the operation may fail.
Error messages and resolutions:
"Unexpected token ... in JSON"
: Check your JSON syntax in the Data (JSON) property."name is required"
: Make sure every folder object includes aname
."403 Forbidden"
or"401 Unauthorized"
: Verify your Directus API credentials and permissions."Parent folder not found"
: Double-check theparent
IDs provided.