Directus icon

Directus

Consume Directus API

Overview

This node integrates with the Directus API to manage permissions in a Directus project. Specifically, the "Permissions" resource with the "Update Multiple" operation allows users to update multiple permission records at once by specifying their primary keys and the data fields to update.

Common scenarios for this node include bulk updating access control rules or permission settings across multiple roles or collections in Directus, which is useful when managing complex permission schemes or automating permission adjustments based on external workflows.

For example, you might use this node to:

  • Update the permissions of several roles simultaneously to grant or revoke access to certain collections.
  • Modify multiple permission entries to change field-level access restrictions in bulk.

Properties

Name Meaning
Data (JSON) A JSON object containing:
- keys: An array of primary keys identifying the permissions to update.
- data: An object with any properties of the permission object to update. This corresponds to the fields and values you want to modify for the selected permissions.

Example of the Data (JSON) property value:

{
  "keys": [34, 65],
  "data": {
    "fields": ["id", "title", "body"]
  }
}

This means update the permissions with IDs 34 and 65, setting their fields property to ["id", "title", "body"].

Output

The node outputs an array of JSON objects representing the response from the Directus API after performing the update operation. Each output item corresponds to the updated permission data returned by the API.

The structure of each JSON output item matches the Directus permission object schema, including updated fields as per the request.

No binary data output is produced by this operation.

Dependencies

  • Requires a valid connection to a Directus instance via an API key credential or other supported authentication method configured in n8n.
  • The node uses the Directus REST API endpoints for permissions management.
  • Proper permissions are required on the Directus API side to perform bulk updates on permissions.

Troubleshooting

  • Invalid Keys or Data Format: If the keys array or data object is malformed or missing required fields, the API will return an error. Ensure that keys is an array of valid permission IDs and data contains valid permission properties.
  • Authentication Errors: If the API credentials are invalid or lack sufficient privileges, the node will fail. Verify the API key or authentication token and ensure it has permission to update permissions.
  • API Rate Limits or Network Issues: Network failures or rate limiting by the Directus server can cause errors. Retry or check network connectivity.
  • JSON Parsing Errors: When entering JSON in the Data (JSON) property, ensure it is valid JSON syntax to avoid parsing errors.

If the node throws errors related to these issues, review the input parameters and credentials accordingly.

Links and References

Discussion