Directus (denkhaus) icon

Directus (denkhaus)

Consume Directus API

Overview

This node creates a new collection in a Directus instance. A "collection" in Directus is similar to a database table, used to store and manage structured data. The node allows you to specify the collection's name, configuration options, and fields to be created at the time of collection creation.

Common scenarios:

  • Automating the setup of new data structures in Directus as part of onboarding or deployment workflows.
  • Dynamically creating collections based on user input or external triggers.
  • Setting up custom metadata, display templates, and field definitions programmatically.

Practical example:
You could use this node to automatically create a new "articles" collection with predefined fields and settings whenever a new project is started in your system.

Properties

Name Type Meaning
Collection String Unique name of the collection to be created (e.g., "articles").
JSON/RAW Parameters Boolean Whether to provide body parameters as raw JSON or via UI key-value pairs.
Body Parameters JSON (If JSON/RAW Parameters is true) Raw JSON object specifying additional properties for the collection.
Additional Fields Collection (If JSON/RAW Parameters is false) Extra configuration options for the collection, such as:
- Archive Field String Field that holds the archive value.
- Archive App Filter String Value to use for filtering archived items.
- Archive Value String Value to use to unarchive items.
- Display Template String Text template for displaying items from this collection.
- Fields (JSON) JSON Array of field definitions to create along with the collection.
- Hidden Boolean Whether the collection is hidden from navigation in the admin app.
- Icon String Google Material Design icon assigned to the collection.
- Note String Description or note about the collection.
- Singleton Boolean Whether the collection should be treated as a single object.
- Sort Field String Field used for sorting items in the collection.
- Translation String Key-value pairs for localizing the collection's name in different languages.
- Unarchive Value String Value indicating how to show the "archived" filter.

Output

The node returns a json object representing the newly created collection. This typically includes:

  • The collection's name and configuration.
  • Any fields created as part of the collection.
  • Metadata such as display template, icon, notes, etc.

Example output:

{
  "collection": "articles",
  "fields": [
    {
      "field": "title",
      "type": "string"
    },
    {
      "field": "content",
      "type": "text"
    }
  ],
  "icon": "people",
  "hidden": false,
  "singleton": false,
  "note": "A collection for articles"
}

Note: The actual structure may vary depending on the Directus API response.

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • Authentication: May require an API key or credentials configured in n8n credentials for Directus.
  • n8n Configuration: Ensure the Directus credentials are set up in n8n.

Troubleshooting

  • Missing Required Fields: If the "Collection" property is not provided, the node will likely throw an error indicating a required parameter is missing.
  • Invalid JSON: If using "Body Parameters" as JSON, ensure the JSON is valid. Invalid JSON will result in parsing errors.
  • Permission Denied: If the API credentials do not have permission to create collections, you may receive a "403 Forbidden" or similar error from Directus.
  • Duplicate Collection Name: Attempting to create a collection with a name that already exists will result in an error from Directus.

Links and References

Discussion