Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Overview

The Webhooks → Create Multiple operation in this n8n node allows you to create multiple webhooks at once in a Directus instance. This is particularly useful for automating the setup of several webhook endpoints that listen to various actions or collections within your Directus project. For example, you might use this operation to register multiple notification endpoints for different content types or events (such as creation, update, or deletion of items).

Practical scenarios:

  • Bulk registering webhooks for all collections in a CMS.
  • Setting up multiple integrations with external services that require notifications on data changes.
  • Automating onboarding processes where each new client/project requires its own set of webhooks.

Properties

Name Type Meaning
Data (JSON) json An array of partial webhook objects. Each object must include name, actions, collections, and url. Used to define webhooks to create.

Details:

  • The property expects an array of objects, each representing a webhook configuration.
  • Required fields per webhook:
    • name: The name of the webhook.
    • actions: Array of actions (e.g., "create", "update", "delete") that trigger the webhook.
    • collections: Array of collection names the webhook applies to.
    • url: The endpoint URL to receive webhook payloads.

Output

  • The output will be a single item with a json field containing the response from the Directus API after creating the webhooks.
  • The structure of the json field typically reflects the created webhook objects as returned by Directus, which may include their IDs, names, actions, collections, URLs, and other metadata.
  • If the Directus API returns a non-object response, it will be wrapped as { "response": ... }.

Example output:

{
  "id": "unique-webhook-id",
  "name": "Example",
  "actions": ["create", "update"],
  "collections": ["articles"],
  "url": "https://example.com",
  // ...other webhook properties
}

If multiple webhooks are created, the response may be an array of such objects.

Dependencies

  • Directus API: You must have access to a running Directus instance.
  • API Credentials: The node requires valid Directus API credentials (directusApi) configured in n8n.
  • n8n Configuration: No special environment variables are required beyond standard credential setup.

Troubleshooting

Common issues:

  • Invalid JSON in Data (JSON): If the input is not a valid JSON array or missing required fields, the node will throw an error. Ensure your input matches the expected format.
  • Missing Required Fields: Each webhook object must include name, actions, collections, and url. Omitting any will result in an error from the Directus API.
  • Permission Errors: The API credentials used must have permission to create webhooks in Directus.
  • API Connectivity Issues: Network problems or incorrect API base URLs can cause connection errors.

Error messages and resolutions:

  • "Unexpected token ... in JSON": Check your JSON syntax in the Data (JSON) property.
  • "Missing required property": Make sure every webhook object includes all required fields.
  • "401 Unauthorized" or "403 Forbidden": Verify your Directus API credentials and permissions.

Links and References

Discussion