Directus icon

Directus

Consume Directus API

Overview

This node integrates with the Directus API to manage webhooks, specifically supporting the creation of multiple webhook entries in one operation. It is useful when you want to programmatically register several webhooks at once, for example, to automate event-driven workflows or synchronize external systems with Directus events.

A practical use case is when setting up a new project where multiple webhooks need to be created to listen to different actions (like create, update, delete) on various collections. Instead of creating each webhook individually, this node allows batch creation, saving time and reducing manual errors.

Properties

Name Meaning
Data (JSON) An array of partial webhook objects to create. Each object must include the following required fields: name (the webhook's name), actions (an array of event types such as "create", "update", "delete"), collections (an array of collection names the webhook listens to), and url (the callback URL for the webhook). This property accepts JSON input and opens an editor window for convenience.

Output

  • The output contains a JSON field representing the response from the Directus API after creating the webhooks.
  • The structure corresponds to the created webhook objects returned by the API.
  • If the API returns multiple created webhook objects, they are included in the output JSON array.
  • No binary data output is produced by this operation.

Dependencies

  • Requires a valid connection to a Directus instance via an API key credential configured in n8n.
  • The node uses the Directus REST API endpoint /webhooks with HTTP POST method.
  • Proper permissions on the Directus instance are necessary to create webhooks.

Troubleshooting

  • Invalid JSON Input: If the JSON provided in the "Data (JSON)" property is malformed, the node will throw a parsing error. Ensure the JSON syntax is correct before execution.
  • Missing Required Fields: Each webhook object must include name, actions, collections, and url. Omitting any of these will likely cause the API to reject the request.
  • API Authentication Errors: If the API key credential is invalid or lacks permissions, the node will fail with authentication errors. Verify the credential and permissions.
  • Network Issues: Connectivity problems to the Directus server will result in request failures. Check network access and Directus server availability.
  • Handling Partial Failures: If some webhook creations fail but others succeed, the node may return partial results or errors depending on the API behavior. Use the "Continue On Fail" option in n8n to handle such cases gracefully.

Links and References

Discussion