Directus icon

Directus

Consume Directus API

Overview

The Directus n8n node, when configured with the Resource: Collection and Operation: Get, retrieves detailed information about a specific collection from a Directus instance. This is useful for automation scenarios where you need to inspect or utilize metadata about a collection—such as its fields, configuration, or other properties—within your workflow.

Common use cases:

  • Dynamically adapting workflows based on collection structure.
  • Validating the existence or schema of a collection before performing further operations.
  • Integrating collection metadata into documentation or reporting processes.

Example:
You might use this operation to fetch the definition of an "articles" collection before creating new items, ensuring your data matches the expected schema.


Properties

Name Type Meaning
Collection options Unique name of the collection to retrieve.

Output

  • The output will be a single object in the json field containing all metadata and configuration details of the specified collection.
  • The structure of the output mirrors the response from the Directus API's /collections/{collection} endpoint, typically including:
    • collection: The collection's unique identifier (string).
    • meta: Metadata about the collection (object), such as display name, icon, note, etc.
    • schema: Schema information (object), such as fields, types, constraints, etc.
    • Other relevant properties as provided by Directus.

Example output:

{
  "collection": "articles",
  "meta": {
    "collection": "articles",
    "icon": "book",
    "note": "Stores article content",
    ...
  },
  "schema": {
    "name": "articles",
    "fields": [
      { "field": "id", "type": "integer", ... },
      { "field": "title", "type": "string", ... }
    ],
    ...
  },
  ...
}

Dependencies

  • Directus API: Requires access to a running Directus instance.
  • API Credentials: You must configure the node with valid Directus API credentials (directusApi).

Troubleshooting

Common issues:

  • Invalid Collection Name: If the specified collection does not exist, the node will return an error from the Directus API.
  • Authentication Errors: Invalid or missing API credentials will result in authentication failures.
  • Insufficient Permissions: The API user must have permission to read collection metadata; otherwise, access will be denied.

Error messages and resolutions:

  • "Collection not found": Check that the collection name is correct and exists in Directus.
  • "Unauthorized" or "Forbidden": Ensure your API credentials are correct and have sufficient permissions.
  • "Network Error": Verify connectivity to the Directus server.

Links and References

Discussion