Actions109
- Activity Actions
- Assets Actions
- Authentication Actions
- Collections Actions
- Extensions Actions
- Fields Actions
- Files Actions
- Folders Actions
- Items Actions
- Permissions Actions
- Presets Actions
- Relations Actions
- Revisions Actions
- Roles Actions
- Settings Actions
- Users Actions
- Utilities Actions
- Webhooks Actions
Overview
This node integrates with the Directus API to manage collections within a Directus project. Specifically, the Collections - Create operation allows users to create a new collection (a database table or data structure) in Directus. This is useful for dynamically defining new data models during automation workflows.
Typical use cases include:
- Automating the setup of new content types or data structures in Directus.
- Creating collections programmatically based on external inputs or events.
- Managing schema changes as part of deployment pipelines.
For example, you could use this node to create a "Products" collection with custom fields and settings, enabling your application to start storing product data immediately after creation.
Properties
| Name | Meaning |
|---|---|
| Collection | Unique name of the collection to be created. For example, "articles" or "products". |
| JSON/RAW Parameters | Boolean flag indicating whether to provide body parameters via UI key-value pairs (false) or as raw JSON (true). |
| Body Parameters | When JSON/RAW Parameters is enabled, this JSON input defines the full body payload for the collection creation request. It allows specifying all collection properties directly in JSON format. |
| Additional Fields | A set of optional fields to customize the collection creation when not using raw JSON. Includes: |
| - Archive Field | Field name that holds the archive status value. |
| - Archive App Filter | Value used to filter "archived" items. |
| - Archive Value | Value used to mark items as "unarchived". |
| - Display Template | Text template defining how items from this collection are displayed across the system. |
| - Fields (JSON) | JSON array defining fields to be created along with the collection. Each field object follows Directus's fields object specification. |
| - Hidden | Boolean indicating if the collection should be hidden from navigation in the admin app. |
| - Icon | Name of a Google Material Design icon assigned to the collection. |
| - Note | Descriptive note about the collection. |
| - Singleton | Boolean indicating if the collection is treated as a single object (singleton). |
| - Sort Field | Field name used for sorting items in the collection. |
| - Translation | Key-value pairs for localized names of the collection in different languages. |
| - Unarchive Value | Value indicating whether to show the "archived" filter. |
Output
The output of the node is a JSON object representing the newly created collection as returned by the Directus API. This typically includes:
- The collection's unique identifier and name.
- Metadata such as fields, display templates, icons, and other configuration details.
- Any additional information provided by Directus upon successful creation.
No binary data output is produced by this operation.
Example output snippet (simplified):
{
"collection": "products",
"fields": [...],
"icon": "shopping_cart",
"note": "Product catalog",
"singleton": false,
...
}
Dependencies
- Requires an active connection to a Directus instance via an API key credential configured in n8n.
- The node uses the Directus REST API endpoints; thus, the Directus server must be accessible from the n8n environment.
- No additional external dependencies beyond the Directus API and n8n credentials.
Troubleshooting
- Invalid JSON in Body Parameters: If using JSON/RAW mode, ensure the JSON syntax is correct. Malformed JSON will cause request failures.
- Missing Required Fields: The
collectionname is mandatory. Omitting it will result in errors. - API Authentication Errors: Ensure the API key credential is valid and has permissions to create collections.
- Permission Denied: The authenticated user must have sufficient rights to create collections in Directus.
- Field Definitions Errors: When providing fields in JSON, ensure they conform to Directus's field object schema to avoid validation errors.
- Network Issues: Verify connectivity to the Directus server and that the endpoint URL is correctly configured.
Common error messages usually come from the Directus API and indicate issues like unauthorized access, invalid payloads, or conflicts with existing collections.
Links and References
- Directus Collections API Reference
- Directus Fields Object Documentation
- Google Material Design Icons
This summary covers the logic and usage of the Directus node's Collections Create operation based on static code analysis and provided property definitions.