Directus icon

Directus

Consume Directus API

Overview

The Directus n8n node's "Users" resource with the "Create Multiple" operation allows you to create multiple user accounts in a Directus instance in a single workflow execution. This is particularly useful for bulk onboarding, migrations, or automating the creation of several users at once (e.g., when importing from another system or spreadsheet).

Practical examples:

  • Importing a list of new employees and creating their Directus accounts.
  • Automating user provisioning from an HR system.
  • Batch-creating test users for development or QA environments.

Properties

Name Type Meaning
Data (JSON) json An array of partial user objects. Each object should contain user details such as email, password, and role. This property is required.

Example value:

[
  {
    "email": "[email protected]",
    "password": "p455w0rd",
    "role": "c86c2761-65d3-43c3-897f-6f74ad6a5bd7"
  },
  {
    "email": "[email protected]",
    "password": "d1r3ctu5",
    "role": "c86c2761-65d3-43c3-897f-6f74ad6a5bd7"
  }
]

Output

  • The output will be a JSON object containing the result of the batch user creation operation.
  • The structure typically matches the response from the Directus API for user creation, which includes the created user objects with their assigned IDs and other properties.

Example output:

{
  "json": [
    {
      "id": "generated-user-id-1",
      "email": "[email protected]",
      "role": "c86c2761-65d3-43c3-897f-6f74ad6a5bd7",
      // ...other user fields
    },
    {
      "id": "generated-user-id-2",
      "email": "[email protected]",
      "role": "c86c2761-65d3-43c3-897f-6f74ad6a5bd7",
      // ...other user fields
    }
  ]
}
  • If an error occurs and "Continue On Fail" is enabled, the output may include 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.
  • User Permissions: The API user must have permission to create users in Directus.

Troubleshooting

Common issues:

  • Invalid JSON in Data (JSON): Ensure the input is a valid JSON array of user objects.
  • Missing Required Fields: Each user object should include all required fields (e.g., email, password, role). Omitting these may cause errors.
  • Role ID Issues: The role field must reference a valid role ID in your Directus instance.
  • Duplicate Emails: Attempting to create users with emails that already exist will result in errors from Directus.
  • Insufficient Permissions: The API credentials used must have sufficient rights to create users.

Error messages:

  • "error": "Field 'email' is required" – Make sure each user object has an email.
  • "error": "Role not found" – Check that the role ID exists in your Directus instance.
  • "error": "Duplicate entry" – A user with this email already exists.

Links and References

Discussion