Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Overview

The Directus (DrWade) n8n node for the resource Settings and operation Update allows you to update the global settings of a Directus instance. This is useful for automating configuration changes, such as updating project URLs, branding, or other system-wide options, directly from your n8n workflows.

Common scenarios:

  • Automating environment-specific settings updates during deployment.
  • Programmatically changing branding or metadata based on workflow triggers.
  • Integrating with CI/CD pipelines to adjust Directus settings after migrations.

Practical example:
You could use this node to update the project_url setting after deploying a new version of your application, ensuring that all users see the correct URL in the Directus admin interface.


Properties

Name Type Meaning
Data (JSON) json A partial settings object. Contains the settings fields you want to update.
JSON/RAW Parameters boolean If enabled, query/body parameters are set via a raw JSON input instead of the UI fields. When true, "Query Parameters" is used; when false, "Update Fields" collection is used.
Query Parameters json (Shown if JSON/RAW Parameters is true) Query parameters as a flat JSON object. Allows advanced users to specify any query string parameters supported by the Directus API.
Update Fields collection (Shown if JSON/RAW Parameters is false) Collection of additional fields to control the update, including aggregation, export options, deep queries, filtering, sorting, etc.
Aggregate fixedCollection Aggregation functions to perform calculations on values (e.g., count, sum, avg) for reporting or analytics purposes.
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 query parameters on nested relational datasets. Useful for complex updates involving related entities.
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 files.
Filter (JSON) json Filters items in the collection by specified conditions.
Group By string Groups results for aggregation, e.g., "Average rating per month".
Meta string Specifies what metadata to return in the response.
Offset number Number of items to skip when fetching data.
Search string Filters items containing the given search query in any field.
Sort string Specifies sort order for returned items. Accepts CSV of fields, minus sign for descending, question mark for random.

Output

  • The node outputs a single item with a json property containing the updated settings object as returned by the Directus API.
  • If the Export option is used, the output may also include a binary property containing the exported data file (in JSON, CSV, or XML format), with the property name as specified by "Binary Property for Export Data".

Example output (JSON):

{
  "json": {
    "project_url": "https://example.com/",
    "...": "other updated settings fields"
  }
}

If exporting:

{
  "json": { ... },
  "binary": {
    "data": {
      "data": "<Buffer ...>",
      "fileName": "export.json",
      "mimeType": "application/json"
    }
  }
}

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure the directusApi credentials in n8n with appropriate permissions to update settings.
  • n8n Environment: No special environment variables required beyond standard n8n and Directus setup.

Troubleshooting

Common issues:

  • Invalid JSON: If the "Data (JSON)" or "Query Parameters" fields contain malformed JSON, the node will throw a parsing error. Double-check your JSON syntax.
  • Insufficient Permissions: If the API credentials lack permission to update settings, you'll receive an authorization error from Directus.
  • Incorrect Field Names: Using invalid or misspelled field names in the settings object will result in errors or ignored updates.
  • Export Errors: If exporting, ensure the "Binary Property for Export Data" is unique and not conflicting with other properties.

Error messages:

  • "Unexpected token ... in JSON": Indicates malformed JSON input.
  • "Request failed with status code 401/403": Authentication or permission issue.
  • "Field does not exist": Invalid field in the settings object.

How to resolve:

  • Validate all JSON inputs using a linter or online tool.
  • Ensure your Directus user has admin or sufficient privileges.
  • Refer to the Directus settings API documentation for valid field names.

Links and References

Discussion