Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Presets → Create Multiple

AI-generated

Overview

The Directus (DrWade) n8n node for the resource Presets and operation Create Multiple allows you to create multiple preset objects in a single API call to a Directus instance. Presets in Directus are used to store user interface preferences, such as default filters, layouts, or sorting options for collections.

Common scenarios:

  • Bulk creation of UI presets for different users or collections during initial project setup.
  • Automating the migration or deployment of preset configurations across environments.
  • Programmatically managing user experience settings for large teams.

Practical example:
Suppose you want to set up default views for several collections for a new user group. You can use this node to send an array of preset definitions, each specifying collection, user, layout, and other preferences, so all presets are created at once.


Properties

Name Type Meaning
Data (JSON) json An array of partial preset objects. Each object defines the configuration for a preset, such as collection, user, layout, search, etc. This property is required.

Output

  • The output will be a JSON object containing the result of the bulk creation operation.
  • The structure typically matches the response from the Directus /presets POST endpoint, which is usually an array of the created preset objects, each with their assigned IDs and properties.
  • Example output:
[
  {
    "id": 1,
    "collection": "directus_files",
    "user": "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca",
    "layout": "cards",
    "search": "Directus",
    ...
  },
  {
    "id": 2,
    "collection": "articles",
    "user": "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca",
    "layout": "tabular",
    ...
  }
]
  • If an error occurs and "Continue On Fail" is enabled, the output will include an error field with the error message.

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure the directusApi credentials in n8n for authentication.
  • No additional environment variables are required beyond standard n8n credential setup.

Troubleshooting

Common issues:

  • Invalid JSON in Data (JSON): If the input is not valid JSON, the node will throw a parsing error. Ensure your array is properly formatted.
  • Missing required fields: Each preset object may require certain fields (e.g., collection, user). Check the Directus preset object documentation.
  • Permission errors: The API user must have permission to create presets. Otherwise, you may receive a 403 Forbidden error.
  • API connection issues: Network or credential misconfiguration will result in connection or authentication errors.

Error messages:

  • "Unexpected token ...": Indicates malformed JSON in the Data (JSON) property.
  • "Request failed with status code 403": Insufficient permissions.
  • "Cannot read property 'data' of undefined": Likely due to an unexpected API response; check your input and Directus server status.

Links and References

Discussion