Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Permissions → Update Multiple

AI-generated

Overview

The Directus (DrWade) n8n node for the resource Permissions with the operation Update Multiple allows you to update multiple permission records in your Directus instance at once. This is particularly useful when you need to modify access rights or rules for several permissions simultaneously, such as updating roles, collections, or actions for a group of users or system components.

Practical scenarios:

  • Bulk updating permissions after a policy change.
  • Automating permission adjustments during onboarding/offboarding processes.
  • Synchronizing permission settings across environments.

Properties

Name Type Meaning
Data (JSON) json A JSON object containing two keys:
- keys: An array of primary keys (IDs) of the permissions you want to update.
- data: An object with the fields and values to update for each specified permission.
Required.

Example input:

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

Output

  • The output will be an array of objects under the json field.
  • Each object represents the updated permission(s) as returned by the Directus API.
  • The structure of each object matches the Directus Permission Object, which typically includes fields like id, role, collection, action, fields, permissions, etc.

Example output:

[
  {
    "id": 34,
    "role": "...",
    "collection": "...",
    "action": "...",
    "fields": ["id", "title", "body"],
    ...
  },
  {
    "id": 65,
    "role": "...",
    "collection": "...",
    "action": "...",
    "fields": ["id", "title", "body"],
    ...
  }
]

Dependencies

  • Directus API: You must have a running Directus instance accessible from n8n.
  • API Credentials: The node requires valid Directus API credentials configured in n8n under the name directusApi.

Troubleshooting

Common issues:

  • Invalid or missing credentials: Ensure your Directus API credentials are correctly set up in n8n.
  • Malformed JSON in "Data (JSON)": If the input is not valid JSON or does not match the expected structure (keys and data), the node will throw a parsing error.
  • Non-existent permission IDs: If any ID in keys does not exist, Directus may return an error or ignore those entries.
  • Insufficient permissions: The API user must have rights to update permissions; otherwise, you'll receive a permission denied error.

Error messages and resolutions:

  • "Unexpected token ... in JSON": Check that your JSON input is properly formatted.
  • "Request failed with status code 403": Your API user lacks sufficient privileges.
  • "Cannot read property 'data' of undefined": The response from Directus was not as expected—check your API endpoint and payload.

Links and References

Discussion