Directus (DrWade) icon

Directus (DrWade)

Consume Directus API

Presets → Create

AI-generated

Overview

The Directus (DrWade) n8n node for the resource Presets with the operation Create allows users to create a new preset in a Directus instance. Presets in Directus are used to store user interface preferences, such as default filters, layouts, and search queries for collections or views.

Common scenarios:

  • Automating the setup of user-specific or role-based UI presets when onboarding new users.
  • Programmatically managing and deploying consistent UI configurations across multiple Directus environments.
  • Integrating preset creation into larger workflows, such as after creating new collections or roles.

Practical example:
When a new user is added to Directus, you can use this node to automatically create a personalized dashboard layout or set default filters for that user.


Properties

Name Type Meaning
Data (JSON) json A partial preset object. This should contain the configuration for the preset, such as user ID, layout type, search query, etc.

Output

  • The output will be a json object representing the newly created preset as returned by the Directus API.
  • The structure of the output will match the Directus Preset Object, typically including fields like:
    • id
    • user
    • role
    • collection
    • layout
    • search
    • filters
    • layout_query
    • bookmark
    • ...and other preset-related properties.

Example output:

{
  "id": 1,
  "user": "410b5772-e63f-4ae6-9ea2-39c3a31bd6ca",
  "layout": "cards",
  "search": "Directus",
  "filters": null,
  "layout_query": null,
  "bookmark": false,
  ...
}

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure the directusApi credentials in n8n with appropriate permissions to create presets.

Troubleshooting

Common issues:

  • Invalid JSON in Data (JSON): If the input is not valid JSON, the node will throw an error. Ensure your JSON is properly formatted.
  • Missing required fields: The Directus API may require certain fields in the preset object (e.g., user, layout). Check the Directus documentation for required fields.
  • Insufficient permissions: If the API credentials do not have permission to create presets, the request will fail with an authorization error.
  • Error handling: If an error occurs and "Continue On Fail" is enabled, the output will include an error field with the error message.

Typical error messages:

  • Invalid JSON: Check your Data (JSON) property for syntax errors.
  • 403 Forbidden or 401 Unauthorized: Verify your API credentials and permissions.
  • 400 Bad Request: Review the preset object for missing or invalid fields.

Links and References

Discussion