Directus (denkhaus) icon

Directus (denkhaus)

Consume Directus API

Overview

This n8n node is designed to create or update (upsert) items in a specified collection. It is particularly useful when you want to ensure that an item exists in your data store: if the item already exists (based on provided filters), it will be updated; otherwise, a new item will be created. This is commonly used for synchronizing data between systems, deduplicating records, or maintaining up-to-date information in a database.

Practical examples:

  • Automatically add or update articles in a CMS from another source.
  • Sync user profiles between two platforms, ensuring no duplicates.
  • Update inventory items with new stock information, creating them if they don't exist.

Properties

Name Meaning
Return All Whether to return all results or only up to a given limit. Options: true (return all), false (limit results).
Limit Max number of results to return. Only shown if "Return All" is false. Accepts values from 1 to 100.
Skip Update Whether to skip the update step if item(s) is/are available. If enabled, existing items matching the filter will not be updated.
Collection Name Unique name of the parent collection where the item will be created or updated. Options are loaded dynamically.
Data (JSON) The partial item object to create or update, provided as JSON. For example:
{
"title": "Hello world!",
"body": "This is our first article"
}
Select items to create or update A collection of filters to select which items should be updated.
└─ Filter (JSON) JSON conditions to select items in the collection. For example:
{ "status": { "_eq": "draft" } }

Output

The output will be a JSON object representing the result of the upsert operation. Typically, this includes:

  • The created or updated item's fields as returned by the API.
  • If multiple items are affected and "Return All" is enabled, an array of such objects may be returned.

Example output:

{
  "id": 123,
  "title": "Hello world!",
  "body": "This is our first article",
  "status": "published"
}

or, if returning multiple items:

[
  {
    "id": 123,
    "title": "Hello world!"
  },
  {
    "id": 124,
    "title": "Another article"
  }
]

Note: This node does not output binary data.

Dependencies

  • Requires access to a Directus instance (API).
  • May require authentication credentials (API key, token, etc.) configured in n8n.
  • The "Collection Name" options are dynamically loaded from the connected Directus instance.

Troubleshooting

Common issues:

  • Invalid Collection Name: If the specified collection does not exist, the node will fail. Ensure the collection name is correct and accessible.
  • Malformed JSON in Data or Filter: If the JSON provided in "Data (JSON)" or "Filter (JSON)" is invalid, the node will throw a parsing error. Double-check your JSON syntax.
  • Insufficient Permissions: If the API credentials do not have permission to create or update items in the selected collection, the operation will fail.
  • Limit Exceeded: If you set a "Limit" outside the allowed range (1–100), the node may throw a validation error.

Error messages and resolutions:

  • "Collection not found" – Check the spelling and existence of the collection in Directus.
  • "Invalid JSON" – Validate your JSON input using a linter or online tool.
  • "Permission denied" – Review your API credentials and permissions in Directus.

Links and References

Discussion