Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Overview

The Directus (DrWade) n8n node with the resource Users and operation Update Multiple allows you to update multiple user records in a Directus instance at once. This is particularly useful for batch operations, such as updating roles, statuses, or other properties for several users simultaneously, saving time compared to updating each user individually.

Practical scenarios:

  • Bulk updating job titles or departments after an organizational change.
  • Disabling or enabling multiple user accounts at once.
  • Assigning a new role to a group of users.

Example:
You have a list of user IDs and want to set their "title" field to "CTO". You provide the array of user keys and the data to update, and the node will apply the changes to all specified users.


Properties

Name Type Meaning
Data (JSON) json A JSON object containing two required fields:
- keys: An array of user primary keys (IDs) to update.
- data: An object with the user fields and values to update. See Directus 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 is a json object representing the result of the bulk update operation from Directus.
  • The structure typically includes the updated user objects or a summary of the update operation, depending on the Directus API response.

Example output:

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

Note: The actual fields returned depend on your Directus configuration and permissions.


Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: The node requires valid Directus API credentials configured in n8n under the name directusApi.
  • n8n Configuration: No special environment variables are needed beyond standard credential setup.

Troubleshooting

Common issues:

  • Invalid or missing user keys: If any provided key does not correspond to an existing user, those users will not be updated, and the API may return an error or partial success.
  • Insufficient permissions: The API credentials used must have permission to update users; otherwise, you'll receive a permission error.
  • Malformed JSON: If the "Data (JSON)" property is not valid JSON or missing required fields (keys, data), the node will throw an error.

Error messages and resolutions:

  • "Cannot read property 'keys' of undefined": Ensure your input JSON contains both keys and data.
  • "Permission denied": Check that your API credentials have the necessary rights in Directus.
  • "400 Bad Request": Double-check the structure of your input JSON and the validity of the user fields being updated.

Links and References


Discussion