Directus icon

Directus

Consume Directus API

Overview

The Invite User operation for the Users resource in this n8n node allows you to send an invitation email to a new user, inviting them to join your Directus instance. This is particularly useful for automating onboarding workflows, where you want to programmatically add users and assign them specific roles without manual intervention.

Practical scenarios:

  • Automate user onboarding when someone fills out a registration form.
  • Batch-invite multiple users as part of a migration or team expansion.
  • Integrate with HR or CRM systems to automatically invite new employees or partners.

Properties

Name Type Meaning
Email String The email address of the user to invite. This is where the invitation will be sent. (Required)
Role String The role ID to assign to the invited user. Determines their permissions within Directus. (Required)
Additional Fields Collection Optional fields to further customize the invitation. Currently includes:
- Invite URL (String): A custom URL for the invite link. Requires configuration of USER_INVITE_URL_ALLOW_LIST in Directus.

Output

  • The output is a JSON object containing the result of the invitation request. Typically, it will include details about the invitation status and possibly the invited user's information.
  • If an error occurs and "Continue On Fail" is enabled, the output will contain an error field with the error message.

Example output:

{
  "id": "12345",
  "email": "[email protected]",
  "role": "c86c2761-65d3-43c3-897f-6f74ad6a5bd7",
  "status": "invited"
}

Note: The actual structure may vary depending on the Directus API response.

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.
  • Environment Variable (optional): To use a custom Invite URL, the Directus instance must have the USER_INVITE_URL_ALLOW_LIST environment variable set appropriately.

Troubleshooting

Common issues:

  • Missing or invalid email/role: Both fields are required. Ensure they are provided and valid.
  • Invalid Invite URL: If you provide a custom invite URL but haven't configured USER_INVITE_URL_ALLOW_LIST, the request may fail.
  • Permission errors: The API credentials used must have permission to invite users and assign the specified role.
  • User already exists: Attempting to invite an email already registered may result in an error from Directus.

Error messages:

  • "Missing required property: email" or "Missing required property: role": Make sure both fields are filled.
  • "Invite URL not allowed": Check your Directus environment variable configuration.
  • "User already exists": The email is already associated with an existing user.

Links and References

Discussion