Directus icon

Directus

Consume Directus API

Overview

This node integrates with the Directus API to update system settings. It allows users to modify various configuration parameters of a Directus instance by sending partial settings objects. This is useful for automating administrative tasks such as changing project URLs, toggling features, or updating metadata without manually accessing the Directus admin interface.

Typical use cases include:

  • Automating environment-specific configuration changes during deployment.
  • Updating settings dynamically based on workflow conditions.
  • Managing Directus configurations programmatically in CI/CD pipelines.

For example, you can update the project URL setting by providing a JSON object like:

{
  "project_url": "https://example.com/"
}

Properties

Name Meaning
Data (JSON) A partial settings object representing the fields and values to update in the Directus system settings. Must be provided as valid JSON.
JSON/RAW Parameters Boolean flag indicating whether query and/or body parameters are set via UI key-value pairs (false) or as raw JSON (true).
Query Parameters When JSON/RAW Parameters is true, this JSON object contains additional query parameters to send with the request.
Update Fields Collection of optional fields to customize the update request, including: aggregate functions, export options, binary property name for export data, deep relational dataset parameters, filters, grouping, sorting, etc.
Aggregate Allows specifying aggregation functions (e.g., count, sum, average) on certain fields when querying data.
Binary Property for Export Data Name of the binary property where exported data will be saved if export is enabled. Defaults to "data".
Deep (JSON) Nested JSON object to specify query parameters on nested relational datasets.
Export Option to save the API response to a file format: JSON, CSV, or XML.
Fields String controlling which fields are returned in the response object.
File Name for Export Data Filename (without extension) used when saving exported data to a file. Defaults to "export".
Filter (JSON) JSON object defining conditions to filter items in the collection.
Group By String specifying fields to group results by, enabling aggregation per group. For example, "author,year(publish_date)".
Meta String specifying what metadata to return in the response.
Offset Number of items to skip when fetching data (pagination).
Search String to filter items containing the given search query in any field.
Sort CSV string defining sort order of returned items. Prefix a field with - for descending order, or use ? for random sorting.

Output

The node outputs the updated settings data in the json field of the output item. The structure corresponds to the Directus settings object after applying the update. If the export option is used, the node also outputs binary data containing the exported file in the specified format (JSON, CSV, or XML) under the configured binary property name.

  • json: Contains the updated settings object returned from the Directus API.
  • binary (optional): Contains exported data file if export is enabled, with appropriate MIME type and filename.

Dependencies

  • Requires an active connection to a Directus instance via an API key credential.
  • The node uses the Directus REST API endpoint /settings with HTTP PATCH method.
  • No additional external dependencies beyond the Directus API and n8n's built-in HTTP request capabilities.

Troubleshooting

  • Invalid JSON input: If the Data (JSON) or other JSON parameters are malformed, the node will throw a parsing error. Ensure all JSON inputs are valid.
  • Authentication errors: If the API key or credentials are invalid or missing, requests will fail with authentication errors. Verify the API key credential configuration.
  • Permission denied: The API user must have permission to update system settings; otherwise, the API will reject the request.
  • Unsupported export format: Only json, csv, and xml are supported for export. Using unsupported formats may cause errors.
  • Network issues: Connectivity problems to the Directus server will result in request failures.
  • To resolve errors, check the error message returned by the node, validate inputs, and ensure proper API access rights.

Links and References

Discussion