Directus icon

Directus

Consume Directus API

Overview

This node integrates with the Directus API to manage data items within custom collections. Specifically, the "Items" resource with the "Create" operation allows users to add new entries to a specified collection in Directus. This is useful for automating content creation workflows, such as adding articles, products, or any structured data managed by Directus.

Practical examples include:

  • Automatically creating new blog posts in a "articles" collection when triggered by an external event.
  • Adding new product entries to an e-commerce catalog collection.
  • Inserting user-submitted form data into a custom collection for further processing.

Properties

Name Meaning
Collection Unique name of the parent collection where the new item will be created.
Data (JSON) The partial item object in JSON format representing the fields and values for the new entry.

Output

The node outputs the response from the Directus API after creating the item. The output is a JSON object containing the newly created item's data as returned by Directus. This typically includes all fields of the item, including any automatically generated IDs or timestamps.

No binary data output is produced by this operation.

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; therefore, the Directus server must be accessible from the n8n environment.
  • Proper permissions are required on the Directus side to create items in the specified collection.

Troubleshooting

  • Invalid Collection Name: If the collection name does not exist or is misspelled, the API will return an error. Verify the collection name matches exactly with the Directus collection.
  • Malformed JSON Data: The "Data (JSON)" property must be valid JSON representing the item fields. Invalid JSON syntax will cause parsing errors.
  • Permission Denied: Insufficient API credentials or permissions will result in authorization errors. Ensure the API key has create access to the target collection.
  • API Connectivity Issues: Network problems or incorrect Directus URL configuration can cause request failures. Confirm network connectivity and correct credential setup.
  • Error Messages: Errors returned by the Directus API are passed through. Common messages include validation errors if required fields are missing or data types are incorrect.

To resolve issues:

  • Double-check input parameters for correctness.
  • Validate JSON syntax before execution.
  • Confirm API credentials and permissions.
  • Review Directus server logs for detailed error information.

Links and References

Discussion