Directus (denkhaus) icon

Directus (denkhaus)

Consume Directus API

Overview

This node allows you to create multiple webhooks in Directus at once. It is particularly useful when you need to register several webhook endpoints for different events or collections in a single workflow step, streamlining bulk setup and management of webhooks.

Common scenarios:

  • Initializing a new Directus project with a predefined set of webhooks.
  • Migrating or synchronizing webhook configurations between environments.
  • Automating the creation of webhooks for multiple collections or actions.

Practical example:
Suppose you want to listen for "create" and "update" events on the "articles" collection and "delete" events separately. You can define both webhooks in one go using this node.

Properties

Name Meaning
Data (JSON) An array of partial webhook objects. Each object must include name, actions, collections, and url. Example values are provided.

Output

The output will be an array of JSON objects representing the created webhooks, as returned by the Directus API. Each object typically includes fields such as:

  • id
  • name
  • actions
  • collections
  • url
  • status
  • other metadata

Example output:

[
  {
    "id": "1",
    "name": "Example",
    "actions": ["create", "update"],
    "collections": ["articles"],
    "url": "https://example.com",
    "status": "active"
  },
  {
    "id": "2",
    "name": "Second Example",
    "actions": ["delete"],
    "collections": ["articles"],
    "url": "https://example.com/on-delete",
    "status": "active"
  }
]

Dependencies

  • Directus instance: You must have access to a running Directus server.
  • API credentials: The node requires authentication (such as an API token or user credentials) with sufficient permissions to create webhooks in Directus.
  • n8n configuration: Ensure that any required credentials for Directus are configured in n8n.

Troubleshooting

Common issues:

  • Invalid JSON input: If the "Data (JSON)" property is not a valid JSON array or is missing required fields (name, actions, collections, url), the node may throw a parsing or validation error.
  • Insufficient permissions: If the provided Directus credentials lack permission to create webhooks, you may receive an authorization error from the API.
  • Duplicate webhook names or URLs: Attempting to create webhooks with duplicate identifiers may result in errors depending on Directus configuration.

Error messages and resolutions:

  • "Invalid JSON": Check your input for correct JSON syntax.
  • "Missing required field": Ensure each webhook object includes all required properties.
  • "Unauthorized" or "Forbidden": Verify your API credentials and permissions.

Links and References

Discussion