Directus icon

Directus

Consume Directus API

Overview

This node integrates with the Directus API to manage permissions on collections within a Directus project. Specifically, the Permissions - Create operation allows users to create new permission rules that define what CRUD (Create, Read, Update, Delete) actions are allowed on specified collections.

Typical use cases include:

  • Automating the setup of access control rules for different user roles or groups.
  • Dynamically creating permissions as part of a workflow when new collections or data structures are added.
  • Managing fine-grained access control in a headless CMS environment via automation.

For example, you might use this node to create a permission that allows users with a certain role to only read from the "customers" collection but not modify it.

Properties

Name Meaning
Collection The target collection to which the permission applies. This is selected from available collections.
Action The CRUD operation the permission rule applies to. Options: create, read, update, delete.
JSON/RAW Parameters Whether to provide the body parameters as key-value pairs or as raw JSON input.
Body Parameters When using JSON/RAW mode, the full body parameters for the permission can be provided here as JSON.

Output

The node outputs the response from the Directus API after creating the permission. The output is a JSON object representing the newly created permission record, including its ID and all properties as stored by Directus.

No binary data output is involved in this operation.

Dependencies

  • Requires an active connection to a Directus instance via an API key or token credential configured in n8n.
  • The node uses the Directus REST API endpoints for permissions management.
  • Proper permissions on the Directus API side are required to create permission rules.

Troubleshooting

  • Invalid Collection or Action: If the collection name or action is invalid or missing, the API will return an error. Ensure the collection exists and the action is one of the allowed CRUD operations.
  • Authentication Errors: If the API credentials are incorrect or expired, authentication errors will occur. Verify the API key/token and permissions.
  • Malformed JSON: When using JSON/RAW parameters, ensure the JSON syntax is correct; otherwise, parsing errors will happen.
  • Permission Conflicts: Creating overlapping or conflicting permission rules may cause unexpected behavior in Directus. Review existing permissions before creating new ones.

Links and References

Discussion