Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Overview

The Directus (DrWade) n8n node for the resource Permissions with the operation Update allows you to update an existing permission rule in a Directus instance. This is useful when you need to programmatically modify access control rules, such as changing what actions a role can perform on a collection or updating filters and fields for permissions.

Common scenarios:

  • Automating updates to user roles and permissions as part of a workflow.
  • Adjusting access rights based on business logic or external triggers.
  • Bulk-updating permission settings across environments.

Example use case:
Suppose your organization changes its policy and now wants to allow editors to delete articles. You could use this node to update the relevant permission rule automatically.


Properties

Name Type Meaning
ID String Primary key of the permission rule to update. Required to identify which rule to modify.
Data (JSON) JSON A partial permissions object. Contains the fields to update in the permission rule.

Output

  • The output will be a single json object representing the updated permission rule as returned by the Directus API.
  • The structure of the output matches the Directus Permission Object, typically including fields like:
    • id
    • role
    • collection
    • action
    • fields
    • permissions
    • validation
    • ...and other permission-related properties.

Example output:

{
  "id": 34,
  "role": "editor",
  "collection": "articles",
  "action": "delete",
  "fields": ["id", "title", "body"],
  "permissions": { /* ... */ },
  "validation": null
}

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure the directusApi credentials in n8n for authentication.

Troubleshooting

Common issues:

  • Invalid ID: If the provided ID does not correspond to an existing permission rule, the API will return an error.
  • Malformed Data (JSON): If the Data (JSON) property is not valid JSON or does not match the expected schema, the request will fail.
  • Insufficient Permissions: The API credentials used must have sufficient rights to update permissions; otherwise, you'll receive an authorization error.

Error messages and resolutions:

  • "Permission not found": Check that the ID is correct and exists in your Directus instance.
  • "Invalid payload" or "Bad Request": Ensure your Data (JSON) is properly formatted and only includes valid fields.
  • "Unauthorized": Verify your API credentials and their associated permissions.

Links and References

Discussion