Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Folders → Create Multiple

AI-generated

Overview

The Folders → Create Multiple operation in this n8n node allows you to create multiple folder records at once in a Directus instance. This is particularly useful for batch-creating organizational structures, such as when initializing a new project, migrating data, or automating the setup of folder hierarchies.

Practical examples:

  • Automatically creating a set of standard folders (e.g., "Invoices", "Contracts", "Reports") for each new client.
  • Migrating an existing folder structure from another system into Directus.
  • Setting up nested folders with parent-child relationships in bulk.

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.

Example input:

[
  {
    "name": "Nature",
    "parent": "0fca80c4-d61c-4404-9fd7-6ba86b64154d"
  },
  {
    "name": "Cities"
  }
]

Output

  • The output will be a single item containing a json field with the response from the Directus API.
  • The structure of the json field will typically be an array of the created folder objects, each including their properties as returned by Directus (such as id, name, parent, etc.).
  • If an error occurs and "Continue On Fail" is enabled, the output will contain an error field with the error message.

Example output:

{
  "json": [
    {
      "id": "generated-folder-id-1",
      "name": "Nature",
      "parent": "0fca80c4-d61c-4404-9fd7-6ba86b64154d",
      ...
    },
    {
      "id": "generated-folder-id-2",
      "name": "Cities",
      "parent": null,
      ...
    }
  ]
}

Note: The actual fields depend on your Directus configuration.

Dependencies

  • Directus API: You must have access to a running Directus instance.
  • API Credentials: The node requires valid Directus API credentials configured in n8n under the name directusApi.

Troubleshooting

Common issues:

  • Invalid JSON: If the Data (JSON) property is not valid JSON, the node will throw a parsing error. Ensure your input is properly formatted.
  • Missing required fields: Each folder object must have a name. Omitting it will result in an error from the Directus API.
  • Parent folder does not exist: If you specify a parent ID that does not correspond to an existing folder, the API may return an error.
  • Permission errors: The API credentials used must have permission to create folders in Directus.

Error messages and resolutions:

  • "Unexpected token ...": Indicates malformed JSON. Double-check your input.
  • "Field 'name' is required": Add the name property to each folder object.
  • "Parent folder not found": Verify the parent ID exists in your Directus instance.
  • "Unauthorized" or "Forbidden": Check your API credentials and permissions.

Links and References

Discussion