Directus icon

Directus

Consume Directus API

Overview

The Webhooks → Update Multiple operation in this n8n node allows you to update multiple webhook records at once in a Directus instance. This is particularly useful when you need to make bulk changes to several webhooks, such as updating their names, URLs, or other properties, without having to update each one individually.

Common scenarios:

  • Renaming or reconfiguring several webhooks after a system migration.
  • Enabling/disabling multiple webhooks in response to a policy change.
  • Updating the target URL for several webhooks due to infrastructure changes.

Practical example:
Suppose you have 10 webhooks that all need to point to a new endpoint. Instead of updating each webhook separately, you can use this operation to update them all in a single request.


Properties

Name Type Meaning
Data (JSON) json The JSON object specifying which webhooks to update and what data to update. It must include:
- keys: An array of primary keys (IDs) of the webhooks to update.
- data: An object with the fields to update.

Example input:

{
  "keys": [15, 41],
  "data": {
    "name": "Build Website"
  }
}

Output

  • The output will be an array of objects under the json field.
  • Each object represents the updated webhook(s) as returned by the Directus API.
  • The structure of each object matches the Directus Webhook object, including fields like id, name, url, status, etc.

Example output:

[
  {
    "json": {
      "id": 15,
      "name": "Build Website",
      "url": "https://example.com/webhook",
      ...
    }
  },
  {
    "json": {
      "id": 41,
      "name": "Build Website",
      "url": "https://example.com/webhook2",
      ...
    }
  }
]

Note: The actual fields depend on your Directus configuration and the properties you update.


Dependencies

  • External Service: Requires access to a Directus instance with API access enabled.
  • Authentication: Needs valid Directus API credentials configured in n8n (via the directusApi credential).
  • n8n Configuration: No special environment variables are required beyond standard credential setup.

Troubleshooting

Common issues:

  • Invalid JSON: If the Data (JSON) property is not valid JSON, the node will throw a parsing error. Double-check your input format.
  • Missing Keys/Data: Both keys and data must be present in the input. Omitting either will result in an error from the Directus API.
  • Permission Denied: The API user must have permission to update webhooks. Otherwise, you'll receive a 403/401 error.
  • Nonexistent IDs: If any ID in keys does not correspond to an existing webhook, Directus may return an error or ignore those IDs.

Error messages:

  • "Unexpected token ...": Indicates malformed JSON in the input.
  • "Request failed with status code 403": Insufficient permissions.
  • "Cannot read property 'data' of undefined": Likely due to an unexpected API response—check your input and Directus server status.

Links and References


Discussion