Directus icon

Directus

Consume Directus API

Overview

The Directus - Users: Update Multiple operation allows you to update multiple user records in your Directus instance at once. This is particularly useful for bulk updates, such as changing the role, status, or other properties of several users simultaneously. For example, you might use this node to promote a group of users to a new role, deactivate multiple accounts, or update profile information in bulk.

Practical scenarios:

  • Updating job titles for a list of users after an organizational change.
  • Bulk enabling/disabling user accounts.
  • Assigning a new role to multiple users at once.

Properties

Name Type Meaning
Data (JSON) json A JSON object containing:
- keys: An array of user primary keys (IDs) to update.
- data: An object with the fields and values to update for each specified user.
See user object docs for available fields.

Example input:

{
  "keys": ["72a1ce24-4748-47de-a05f-ce9af3033727", "9c3d75a8-7a5f-41a4-be0a-1488fd974511"],
  "data": {
    "title": "CTO"
  }
}

Output

  • The output will be a single item with a json field containing the API response from Directus.
  • The structure of the response typically includes the updated user objects or a summary of the update operation, depending on the Directus API version and configuration.

Example output:

{
  "json": {
    "data": [
      {
        "id": "72a1ce24-4748-47de-a05f-ce9af3033727",
        "title": "CTO",
        "...": "other user fields"
      },
      {
        "id": "9c3d75a8-7a5f-41a4-be0a-1488fd974511",
        "title": "CTO",
        "...": "other user fields"
      }
    ]
  }
}
  • If an error occurs and "Continue On Fail" is enabled, the output will contain an error property 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.

Troubleshooting

Common issues:

  • Invalid or missing user IDs: If any ID in the keys array does not exist, the API may return an error or skip that user.
  • Insufficient permissions: The API credentials used must have permission to update users.
  • Malformed JSON: Ensure the Data (JSON) property is valid JSON and matches the required structure.
  • Field validation errors: Attempting to update fields with invalid data types or values not allowed by Directus will result in errors.

Error messages and resolutions:

  • "Cannot read property 'data' of undefined": Check that the API response contains the expected data; verify your input and Directus instance.
  • "Invalid credentials": Make sure your Directus API credentials are correct and have sufficient permissions.
  • "Validation failed": Review the data object to ensure all fields and values are valid according to the Directus user schema.

Links and References

Discussion