Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Items → Update Multiple

AI-generated

Overview

The Directus (DrWade) node for n8n, when configured with the resource Items 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.

Common scenarios:

  • Publishing or unpublishing multiple content items (e.g., articles, products).
  • Bulk updating fields like tags, categories, or statuses across many records.
  • Efficiently managing large datasets without making individual update requests for each item.

Practical example:
You have a collection called articles and want to set the status of articles with IDs 1 and 2 to "published". You can use this operation to update both items in one go.

Properties

Name Type Meaning
Data (JSON) json An object containing an array of item keys (keys) to update and a data object with the new field values. See Directus item object. Example:
{
"keys": [1, 2],
"data": {
"status": "published"
}
}
Collection options The unique name of the parent collection where the items reside (e.g., articles).

Output

  • The output will be a JSON object representing the result of the batch update operation from Directus.
  • The structure typically matches the Directus Items API response, which may include:
    • An array of updated item objects, each reflecting the new state after the update.
    • If the API returns a different structure (such as a summary or count), it will be passed through as-is.

Example output:

{
  "data": [
    {
      "id": 1,
      "status": "published",
      "...": "..."
    },
    {
      "id": 2,
      "status": "published",
      "...": "..."
    }
  ]
}

Note: The actual fields depend on your collection schema.

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure the directusApi credentials in n8n with appropriate permissions to update items in the target collection.

Troubleshooting

Common issues:

  • Invalid Collection Name: If the collection does not exist, you'll receive an error from Directus.
  • Malformed Data (JSON): If the data property is not valid JSON or missing required fields, the node will throw a parsing or validation error.
  • Permission Denied: If the API credentials lack permission to update items, the request will fail.
  • Item Not Found: If any of the provided keys do not correspond to existing items, those updates may be skipped or cause errors depending on Directus configuration.

Error messages and resolutions:

  • "Cannot read property 'keys' of undefined": Ensure your Data (JSON) input includes a keys array and a data object.
  • "Collection not found": Double-check the Collection value.
  • "Unauthorized" or "Forbidden": Verify your API credentials and their permissions.

Links and References

Discussion