Directus icon

Directus

Consume Directus API

Overview

The Directus - Permission: Update operation in this n8n node allows you to update an existing permission rule in a Directus instance. This is useful for programmatically managing access control, such as modifying what actions users or roles can perform on collections or items within your Directus project.

Common scenarios:

  • Automating updates to permissions when onboarding new teams or changing organizational policies.
  • Integrating with other systems to dynamically adjust access rights based on external triggers.
  • Bulk updating permission rules as part of migration or deployment scripts.

Practical example:
Suppose you need to restrict the "delete" action for a specific role on a collection whenever a certain event occurs in your workflow. 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.
Data (JSON) JSON A partial permissions object containing the fields to update.

Output

  • The output will be a json object representing the updated permission rule as returned by the Directus API.
  • The structure of the output matches the Directus Permission Object, which typically includes fields like id, role, collection, action, fields, permissions, etc.
  • Example output:
    {
      "id": 34,
      "role": "12345678-abcd-efgh-ijkl-1234567890ab",
      "collection": "articles",
      "action": "read",
      "fields": ["id", "title", "body"],
      "permissions": { /* ... */ },
      // ...other fields
    }
    

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure the directusApi credentials in n8n for authentication.
  • No additional environment variables are required beyond standard n8n credential setup.

Troubleshooting

Common issues:

  • Invalid ID: If the provided ID does not correspond to an existing permission rule, the node will throw an error.
  • Malformed Data (JSON): If the JSON provided in "Data (JSON)" is invalid 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 a permission denied error from Directus.

Error messages and resolutions:

  • "Cannot find permission rule with ID X": Double-check the ID value.
  • "Invalid JSON in 'Data (JSON)'": Ensure your JSON is properly formatted.
  • "Permission denied": Verify that your API credentials have admin or appropriate access.

Links and References

Discussion