Directus (DrWade) icon

Directus (DrWade)

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 for bulk management of webhooks, such as renaming several webhooks or changing their configuration properties in a single API call.

Practical scenarios:

  • You need to change the name or URL of several webhooks after migrating services.
  • You want to enable/disable multiple webhooks based on new business rules.
  • You are performing batch updates as part of a deployment or integration process.

Example:
You have webhooks with IDs 15 and 41, and you want to update their name property to "Build Website" in one go.

Properties

Name Type Meaning
Data (JSON) json JSON object containing:
- keys: Array of primary keys (IDs) of the webhooks to update.
- data: Object with the fields and values to update for each webhook.
See webhook object docs for available properties.

Example input:

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

Output

  • The output will be a JSON object reflecting the result of the update operation from Directus.
  • The structure typically matches the response from the Directus PATCH /webhooks endpoint, which may include an array of updated webhook objects or a summary of the update operation.

Example output:

{
  "data": [
    {
      "id": 15,
      "name": "Build Website",
      // ...other webhook properties
    },
    {
      "id": 41,
      "name": "Build Website",
      // ...other webhook properties
    }
  ]
}
  • If the response is not an object, it will be wrapped as { "response": <value> }.

Dependencies

  • Directus API: Requires access to a Directus instance.
  • API Credentials: You must configure the directusApi credentials in n8n for authentication.

Troubleshooting

Common issues:

  • Invalid JSON in Data (JSON): Ensure your input is valid JSON. Malformed JSON will cause parsing errors.
  • Missing or incorrect keys: The keys array must contain valid webhook IDs. If any ID does not exist, those webhooks will not be updated.
  • Insufficient permissions: The API user must have permission to update webhooks in Directus.
  • Error messages:
    • "Cannot read property 'data' of undefined": Likely due to an unexpected API response; check your input and Directus server status.
    • "Request failed with status code 403": Indicates insufficient permissions.
    • "Invalid value for field": One or more properties in the data object do not match the expected schema for webhooks.

How to resolve:

  • Double-check your JSON syntax and required fields.
  • Verify that the webhook IDs exist in your Directus instance.
  • Ensure your API credentials have the necessary permissions.

Links and References

Discussion