Actions100
- Activity Actions
- Asset Actions
- Authentication Actions
- Collection Actions
- Extension Actions
- Field Actions
- File Actions
- Folder Actions
- Item Actions
- Permission Actions
- Preset Actions
- Relation Actions
- Revisions Actions
- Roles Actions
- Settings Actions
- Users Actions
- Utilities Actions
Overview
The Directus - Permission: Create Multiple operation in this n8n node allows you to create multiple permission objects at once in a Directus instance. This is particularly useful for administrators or developers who need to set up or update access control rules for various roles and collections in bulk, rather than creating each permission individually.
Common scenarios:
- Initial setup of a new Directus project where many permissions must be defined.
- Migrating or synchronizing permissions between environments.
- Automating the management of complex role-based access controls.
Practical example:
You have several user roles (e.g., "Editor", "Viewer") and want to grant them different levels of access (read, create, update) to various collections (like "pages" or "posts"). Instead of manually adding each permission, you can use this operation to submit an array of permission definitions in one go.
Properties
Name | Type | Meaning |
---|---|---|
Data (JSON) | json | An array of partial permissions objects. Each object should specify at least action and collection . Used to define permissions. |
Details:
- The property expects a JSON array, where each element represents a permission object.
- Each permission object typically includes fields like
collection
,action
,role
, and optionallyfields
. - Example input:
[ { "collection": "pages", "action": "read", "role": "c86c2761-65d3-43c3-897f-6f74ad6a5bd7", "fields": ["id", "title"] }, { "collection": "pages", "action": "create", "role": "c86c2761-65d3-43c3-897f-6f74ad6a5bd7", "fields": ["id", "title"] } ]
Output
- The output will be a single item with a
json
field containing the result from the Directus API after creating the permissions. - The structure of the output
json
field will match the response from the Directus/permissions
POST endpoint, typically including details about the created permissions (such as their IDs and properties). - If the API returns an error and "Continue On Fail" is enabled, the output will contain an
error
field with the error message.
Example output:
{
"json": [
{
"id": 123,
"collection": "pages",
"action": "read",
"role": "c86c2761-65d3-43c3-897f-6f74ad6a5bd7",
"fields": ["id", "title"],
...
},
{
"id": 124,
"collection": "pages",
"action": "create",
"role": "c86c2761-65d3-43c3-897f-6f74ad6a5bd7",
"fields": ["id", "title"],
...
}
]
}
Note: The actual fields returned depend on your Directus version and configuration.
Dependencies
- Directus API: You must have access to a running Directus instance.
- API Credentials: The node requires valid Directus API credentials configured in n8n under the name
directusApi
.
Troubleshooting
Common issues:
- Invalid JSON: If the "Data (JSON)" property is not a valid JSON array, the node will throw a parsing error.
- Missing required fields: Each permission object must include at least
action
andcollection
. Omitting these will cause the API to reject the request. - Permission denied: The API credentials used must have sufficient rights to create permissions; otherwise, you'll receive an authorization error.
- Malformed permission objects: If any object in the array does not conform to the expected schema, the entire request may fail.
Error messages and resolutions:
"Unexpected token ... in JSON"
: Check that your JSON input is correctly formatted."Field 'action' is required"
: Ensure every permission object includes theaction
property."Not authorized"
: Verify your API credentials and their permissions in Directus.