Directus icon

Directus

Consume Directus API

Overview

The Users → Delete Multiple operation in this n8n node allows you to delete multiple user records from a Directus instance in a single workflow execution. This is particularly useful for bulk user management tasks, such as cleaning up test accounts, removing users who no longer need access, or automating deprovisioning processes.

Practical examples:

  • Removing a list of users whose IDs are provided by another step in your workflow.
  • Automating the deletion of users based on inactivity or other criteria.
  • Integrating with HR systems to remove users who have left an organization.

Properties

Name Type Meaning
Keys (JSON) JSON An array of user primary keys (IDs) to be deleted. Example: ["id1", "id2", ...]

Output

  • The output will be a single item with a json field containing the response from the Directus API after attempting to delete the specified users.
  • The structure of the json output typically reflects the Directus API's response for a bulk delete operation. This may include:
    • A summary of the deletion result (e.g., number of users deleted).
    • Any errors encountered during the process.
    • If the operation fails for some users but not others and "Continue On Fail" is enabled, the output may contain error messages for those specific users.

Example output:

{
  "json": {
    // Directus API response, e.g.,
    "data": {
      // Details about deleted users or status
    }
  }
}

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure the directusApi credentials in n8n with appropriate permissions to delete users.

Troubleshooting

Common issues:

  • Invalid or missing user IDs: If any of the provided keys do not correspond to existing users, the API may return an error for those entries.
  • Insufficient permissions: The API credentials used must have permission to delete users; otherwise, the operation will fail.
  • Malformed JSON: The "Keys (JSON)" property must be a valid JSON array of strings. Invalid JSON will cause the node to throw a parsing error.

Error messages and resolutions:

  • "Cannot read property 'forEach' of undefined": Ensure that the "Keys (JSON)" input is a valid array.
  • "Request failed with status code 403": Check that your API credentials have sufficient permissions.
  • "Unexpected token ... in JSON at position ...": Double-check the JSON syntax in the "Keys (JSON)" field.

Links and References

Discussion