Directus (denkhaus) icon

Directus (denkhaus)

Consume Directus API

Overview

The Setting: Update operation in this custom n8n node allows you to update system settings via the Directus API. This is useful for automating configuration changes, such as updating project URLs, toggling features, or modifying other global settings in a Directus instance. Typical scenarios include DevOps automation, environment setup, or dynamic reconfiguration of application parameters.

Practical examples:

  • Automatically updating the project URL after a deployment.
  • Changing feature flags based on workflow conditions.
  • Exporting current settings to a file (CSV, JSON, XML) for backup or migration.

Properties

Name Meaning
JSON/RAW Parameters Whether to set query/body parameters using a key-value UI (false) or as raw JSON (true).
Query Parameters Query parameters as a flat JSON object. Used when "JSON/RAW Parameters" is true.
Additional Fields Collection of advanced options for the request. Includes:
- Aggregate: Perform calculations (avg, count, sum, etc.) on fields.
- Binary Property for Export Data: Name of binary property for downloaded data.
- Deep (JSON): Set nested relational query parameters.
- Export: Save response as json, csv, or xml.
- File Name for Export Data: Filename without extension.
- Fields: Specify which fields to return.
- Filter (JSON): Filter items by conditions.
- Group By: Group results by field(s).
- Meta: Metadata to return.
- Offset: Skip N items.
- Search: Search query string.
- Sort: Sorting instructions (CSV of fields, use '-' for descending, '?' for random).
Data (JSON) The partial settings object to update. Must be valid JSON. Example:
{"project_url": "https://example.com/"}

Output

  • The node outputs a json field containing the updated settings object as returned by the Directus API.
  • If the "Export" option is used, the output may include a binary property (default name: data) containing the exported file in the selected format (CSV, JSON, or XML).

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • Authentication/API Key: May require an API token or credentials configured in n8n for authentication with Directus.
  • n8n Configuration: No special environment variables are indicated, but ensure network access to the Directus server.

Troubleshooting

Common issues:

  • Invalid JSON: If the "Data (JSON)" or any JSON field contains invalid syntax, the node will throw a parsing error. Double-check your JSON formatting.
  • Missing Required Fields: Omitting required properties like "Data (JSON)" or "Query Parameters" (when needed) will result in errors.
  • Permission Denied: If the API credentials lack permission to update settings, you'll receive an authorization error from Directus.
  • Incorrect Export Format: Specifying an unsupported export format will cause the request to fail.

Error messages and resolutions:

  • "Invalid JSON": Ensure all JSON fields are properly formatted.
  • "401 Unauthorized" or "403 Forbidden": Check your API credentials and permissions.
  • "400 Bad Request": Review the structure of your input data and required fields.

Links and References

Discussion