Skip to main content

What are Items?

Items are the individual pieces of data stored within collections. Each item represents a single row in a database table and contains values for all the fields defined in its parent collection. Items are the core content objects you create, read, update, and delete through the Directus API.
Every item is uniquely identified by its primary key, typically an auto-incrementing integer or UUID.

Item Structure

An item consists of field-value pairs corresponding to the collection’s schema:

Creating Items

Items are created through the API by providing field values:
From the source code (~/workspace/source/api/src/services/items.ts:126-169), the creation process:
  1. Validates the payload against permissions
  2. Runs pre-create hooks for modifications
  3. Processes presets from permissions
  4. Handles Many-to-One (M2O) relationships
  5. Handles Any-to-One (A2O) relationships
  6. Inserts the record into the database
  7. Processes One-to-Many (O2M) relationships
  8. Returns the primary key of the new item

Auto-Generated Fields

Certain fields are automatically populated:
  • Primary Key: Auto-incremented unless manually specified
  • user_created: Set to the authenticated user’s ID
  • date_created: Set to current timestamp
  • Default Values: Applied from field schema

Reading Items

Get All Items

Returns a list of all items in the collection (subject to permissions).

Get Single Item

Retrieve a specific item by its primary key.

Query Parameters

Directus provides powerful query parameters for filtering, sorting, and pagination:

Filtering

Field Selection

Supports nested field selection through relationships using dot notation.

Sorting

Prefix with - for descending order.

Pagination

Or use offset-based pagination:
Searches across all searchable fields in the collection.

Updating Items

Update Single Item

Update Multiple Items

Update multiple items by their IDs:
Or update by query:

Auto-Updated Fields

  • user_updated: Set to the authenticated user’s ID
  • date_updated: Set to current timestamp

Deleting Items

Delete Single Item

Delete Multiple Items

Or by IDs:
Deleting items is permanent unless you have revisions enabled. Always ensure you have backups before bulk deletions.

Item Revisions

When revisions are enabled for a collection, Directus tracks every change to items:
Each change creates a revision record in directus_revisions:
You can revert to previous revisions through the API or app interface.

Item Activity

When accountability is enabled, all item actions are logged in directus_activity:
Activities include:
  • create - Item creation
  • update - Item modification
  • delete - Item deletion
  • comment - Comments added to item

Nested Relational Data

Items can include related data from other collections through field expansion:
Response includes full related objects:

Deep Nesting

Supports deep nesting of relationships:

Creating Items with Relationships

Create related items inline during item creation:
From the source code (~/workspace/source/api/src/services/items.ts:203-216), relationship processing handles:
  1. M2O (Many-to-One): Creates related item first, uses returned ID
  2. A2O (Any-to-One): Similar to M2O with collection specification
  3. O2M (One-to-Many): Creates child items after parent, linking via foreign key

Batch Operations

Directus supports efficient batch operations:

Create Multiple Items

Update Multiple Items

Batch mutations have a configurable limit (default 25,000 mutations) to prevent performance issues.
From the source code (~/workspace/source/api/src/services/items.ts:89-104):

Singleton Items

For singleton collections, use a simplified API:
No ID needed since only one item exists.

Common Use Cases

Content Publishing

Create, edit, and publish blog posts, articles, and pages with draft/published workflows.

Product Catalogs

Manage e-commerce products with variants, pricing, inventory, and categorization.

User Profiles

Store user information, preferences, and settings with custom profile data.

Asset Metadata

Enrich media files with tags, descriptions, credits, and licensing information.

Best Practices

Use Transactions: For complex operations involving multiple items or collections, leverage database transactions for atomicity.
Batch Operations: When creating or updating multiple items, use batch endpoints instead of individual requests.
Field Selection: Only request the fields you need to reduce response payload size and improve performance.
Enable Revisions: For important content collections, enable revisions to track changes and allow rollbacks.
Optimize Queries: Use filters, limits, and indexes appropriately to ensure fast query performance.