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 node for n8n, when configured with the Resource: Item and Operation: Update Multiple, allows you to update multiple items in a specified Directus collection in a single API call. This is particularly useful for batch updates, such as changing the status of several articles at once or applying bulk edits to records.
Practical scenarios:
- Publishing or unpublishing multiple content items (e.g., articles, products) simultaneously.
- Updating a specific field (like "status" or "category") across many records based on their IDs.
- Bulk editing user data or other custom collections in your Directus instance.
Example:
You have a list of article IDs and want to set their status to "published" in one go.
Properties
Name | Type | Meaning |
---|---|---|
Data (JSON) | json | An object containing an array of item keys (keys ) and the partial item data (data ) to update. |
Collection | options | The unique name of the parent collection where the items reside. |
Details:
Data (JSON):
- Expects a JSON object like:
{ "keys": [1, 2], "data": { "status": "published" } }
keys
: Array of item primary keys (IDs) to update.data
: Partial object with fields and values to update for each item.
- Expects a JSON object like:
Collection:
- The target collection's name (e.g.,
"articles"
).
- The target collection's name (e.g.,
Output
- The output will be an array of objects, each with a
json
property containing the response from Directus. - The structure of the
json
field typically reflects the updated items as returned by the Directus API. For example:{ "json": { "id": 1, "status": "published", ... } }
- If the operation fails and "Continue On Fail" is enabled, the output will contain an error message:
{ "json": { "error": "Error message here" } }
Dependencies
- External Service: Requires access to a Directus instance (API endpoint).
- Authentication: Needs valid Directus API credentials configured in n8n under the credential type
directusApi
. - n8n Configuration: No special environment variables are required beyond standard credential setup.
Troubleshooting
Common Issues:
- Invalid Collection Name: If the collection does not exist, Directus will return an error.
- Malformed Data (JSON): If the JSON is invalid or missing required fields (
keys
,data
), the request will fail. - Permission Denied: The API credentials must have permission to update items in the specified collection.
- Nonexistent Keys: If any of the provided keys do not correspond to existing items, those updates may fail or be ignored.
Typical Error Messages:
"Collection not found"
: Check the collection name."Invalid payload"
or"Malformed JSON"
: Ensure the Data (JSON) property is correctly formatted."Unauthorized"
or"Forbidden"
: Verify your API credentials and permissions."Item(s) not found"
: Double-check the IDs in thekeys
array.