Directus icon

Directus

Consume Directus API

Overview

This node integrates with the Directus API to manage data items within custom collections. Specifically, the "Create Multiple" operation under the "Items" resource allows users to create multiple new entries in a specified collection at once by sending an array of item objects.

This operation is beneficial when you need to bulk insert data into a Directus-managed database, such as importing multiple articles, products, or records simultaneously. For example, if you have a list of new blog posts or inventory items in JSON format, you can use this node to add them all in one request, improving efficiency and reducing API calls.

Properties

Name Meaning
Collection Unique name of the parent collection where the items will be created. This must be selected from available non-system collections.
Data (JSON) An array of partial item objects in JSON format representing the data to be created in the collection. Each object corresponds to one new item.

Output

The output contains the response from the Directus API after creating the multiple items. The json field includes the newly created items' data as returned by the API, typically including their assigned IDs and any other fields that were set or generated.

No binary data output is produced by this operation.

Dependencies

  • Requires a valid connection to a Directus instance via an API key credential.
  • The node uses the Directus REST API endpoints for items management.
  • Proper permissions on the Directus side are necessary to create items in the specified collection.
  • No additional environment variables are required beyond the configured Directus API credentials.

Troubleshooting

  • Invalid Collection Name: If the collection name is incorrect or refers to a system collection, the API will return an error. Ensure the collection exists and is not a system collection.
  • Malformed JSON Data: The "Data (JSON)" property must be a valid JSON array of objects. Invalid JSON syntax or structure will cause parsing errors.
  • Permission Denied: Lack of proper permissions to create items in the collection will result in authorization errors.
  • API Connectivity Issues: Network problems or incorrect API credentials will prevent successful requests.
  • Large Payloads: Sending very large arrays might hit API limits or timeouts; consider splitting data into smaller batches.

To resolve these issues:

  • Verify the collection name and existence in your Directus instance.
  • Validate the JSON data before inputting it.
  • Check user roles and permissions in Directus.
  • Confirm API credentials and network connectivity.

Links and References

Discussion