Directus icon

Directus

Consume Directus API

Overview

The Directus node for n8n, when configured with the Resource: Settings and Operation: Update, allows you to update the global settings of a Directus instance. This is useful for programmatically changing configuration options such as project URLs, branding, or other system-wide preferences without manual intervention in the Directus admin interface.

Common scenarios:

  • Automating environment-specific settings updates during deployment.
  • Synchronizing settings across multiple Directus instances.
  • Integrating external systems that need to adjust Directus configuration dynamically.

Example use case:
You want to update the project_url and enable/disable certain features in Directus as part of your CI/CD pipeline after deploying a new version of your application.


Properties

Name Type Meaning
Data (JSON) json A partial settings object. Contains the settings fields and values you wish to update. Required.
JSON/RAW Parameters boolean If enabled, allows you to provide query/body parameters as raw JSON instead of using the UI fields. When true, "Query Parameters" must be used; when false, "Update Fields" collection is used.
Query Parameters json (Shown if JSON/RAW Parameters is true) Additional query parameters as a flat JSON object. Used to further customize the API request.
Update Fields collection (Shown if JSON/RAW Parameters is false) Allows you to specify additional fields for the update, such as aggregation, export options, deep queries, filters, sorting, etc.
Aggregate fixedCollection Aggregation functions to perform calculations on settings data (rarely used for settings, but available for consistency).
Binary Property for Export Data string Name of the binary property to which exported data will be written if exporting.
Deep (JSON) json Allows setting nested relational dataset query parameters.
Export options If set, saves the API response to a file in one of the formats: json, csv, xml.
Fields string Controls which fields are returned in the response object.
File Name for Export Data string The filename (without extension) for exported data.
Filter (JSON) json Conditions to filter items in the collection (not typically relevant for settings, but present for consistency).
Group By string Groups results by specified fields (not typically relevant for settings).
Meta string Specifies what metadata to return in the response.
Offset number Number of items to skip when fetching data (not typically relevant for settings).
Search string Search query to filter items (not typically relevant for settings).
Sort string Sorting order for returned items (not typically relevant for settings).

Output

  • The output is an object under the json key containing the updated settings as returned by the Directus API.
  • If the Export option is used, binary data will also be included under the specified binary property name, containing the exported settings in the chosen format (json, csv, or xml).

Example output (json):

{
  "id": "1",
  "project_url": "https://example.com/",
  "branding": {
    "logo": "custom-logo.png"
  },
  ...
}
  • The exact structure depends on which settings were updated and the Directus version.

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure the node with valid Directus API credentials (typically an API token or user/password).
  • n8n Configuration: No special environment variables required beyond standard credential setup.

Troubleshooting

Common issues:

  • Invalid JSON: If the Data (JSON) or any JSON field contains invalid JSON, the node will throw a parsing error. Double-check your syntax.
  • Insufficient Permissions: The API credentials used must have permission to update settings. Otherwise, you'll receive a 403 Forbidden or similar error.
  • Incorrect Field Names: Using incorrect keys in the settings object may result in no changes or errors from the API.
  • Export Errors: If exporting, ensure the binary property name does not conflict with existing properties.

Error messages and resolutions:

  • "Unexpected token ... in JSON": Check your JSON input for syntax errors.
  • "403 Forbidden": Ensure your API credentials have sufficient permissions.
  • "400 Bad Request": Review the structure of your settings object and query parameters.

Links and References

Discussion