Directus icon

Directus

Consume Directus API

Overview

The "Sort Items" operation in the Utilities resource of this Directus node allows you to reorder items within a specified collection. Specifically, it moves an item identified by its primary key to a new position relative to another item in the same collection.

This operation is useful when managing ordered lists or sequences stored in Directus collections, such as sorting tasks in a project management app, ordering products in a catalog, or arranging menu items on a website.

Example use case:
You have a collection of articles displayed in a custom order on your website. Using this node, you can move an article (item) to a new position before or after another article (target item), updating the order accordingly.

Properties

Name Meaning
Collection The identifier of the collection where the items exist and need to be reordered.
Item The primary key of the item that you want to move within the collection.
To The primary key of the target item indicating the position where the current item should be moved to.

Output

The output JSON contains the response from the Directus API after performing the sort operation. Typically, this will include confirmation of the reorder action or the updated state of the collection's items.

If the API returns a simple value (string, number, boolean), it is wrapped inside an object with a result property for consistency.

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 endpoint POST utils/sort/{collection} to perform the sorting.
  • Proper permissions are needed on the Directus side to reorder items in the specified collection.

Troubleshooting

  • Invalid Collection Identifier: Ensure the collection name provided exists in your Directus instance. Use the "Collection" dropdown or load options to select a valid collection.
  • Incorrect Item or To IDs: Both Item and To must be valid primary keys of items within the specified collection. Invalid or non-existent IDs will cause API errors.
  • Permission Denied: The API user must have permission to modify the order of items in the collection.
  • API Errors: If the Directus API returns errors, check the error message for details. Common issues include network connectivity, authentication failures, or invalid request payloads.
  • Continue On Fail: If enabled, the node will continue processing other items even if one fails, returning error messages in the output JSON.

Links and References

Discussion