Directus icon

Directus

Consume Directus API

Overview

This node integrates with the Directus API to manage users within a Directus instance. Specifically, the Users - Create operation allows you to create a new user by providing essential details such as email and password, along with optional additional user information.

Common scenarios where this node is beneficial include:

  • Automating user onboarding workflows by programmatically creating users.
  • Integrating user creation into broader automation pipelines, e.g., after form submissions or CRM updates.
  • Managing user accounts in bulk or via custom logic without manual intervention.

Practical example:

  • When a new customer signs up on your platform, use this node to automatically create a corresponding user in your Directus backend with their email, password, and profile details like name and role.

Properties

Name Meaning
Email The email address of the new user. This is required and uniquely identifies the user.
Password The password for the new user account. Required for authentication purposes.
JSON/RAW Parameters Boolean flag to choose between entering parameters via UI fields or providing raw JSON input for the request body.
Body Parameters Raw JSON or RAW input for the request body when JSON/RAW Parameters is enabled. Allows full customization of the user object sent to Directus.
Additional Fields Optional collection of extra user properties:
- Avatar Reference to an avatar file (many-to-one relation to files).
- Description A textual description of the user.
- First Name User's first name.
- Language Language code for the Admin App interface (e.g., "en-US"). See Directus locales for available options.
- Last Name User's last name.
- Location User's location (e.g., city or region).
- Role Role assigned to the user. Options are dynamically loaded from available roles in Directus.
- Tags Tags associated with the user for categorization or filtering.
- TFA Secret Two-Factor Authentication secret key for enhanced security.
- Theme Preferred theme for the Admin App interface. Options: Auto, Light, Dark.
- Title Job title or designation of the user.

Output

The node outputs the created user object in the json field of the output data. This object contains all the user properties as returned by the Directus API, including any default or system-generated fields such as user ID, timestamps, and metadata.

No binary data output is produced by this operation.

Example output snippet (simplified):

{
  "id": "1234",
  "email": "another@example.com",
  "first_name": "Admin",
  "last_name": "User",
  "role": "role_id",
  "language": "en-US",
  "theme": "auto",
  "created_at": "2023-01-01T12:00:00Z",
  ...
}

Dependencies

  • Requires a valid connection to a Directus instance via an API key credential or equivalent authentication token configured in n8n.
  • The node uses the Directus REST API endpoints for user management.
  • No additional external dependencies beyond the Directus API and n8n environment.

Troubleshooting

  • Missing required fields error: Ensure that both Email and Password are provided when not using raw JSON input.
  • Invalid JSON format: When using the JSON/RAW Parameters option, ensure the JSON syntax is correct to avoid parsing errors.
  • Authentication failures: Verify that the API credentials used have sufficient permissions to create users in the Directus instance.
  • Role not found: If assigning a role, confirm that the role exists in Directus; roles are dynamically loaded but may be outdated if roles were recently changed.
  • API rate limits or network issues: Check connectivity and API usage limits if requests fail intermittently.

Links and References

Discussion