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:~/workspace/source/api/src/services/items.ts:126-169), the creation process:
- Validates the payload against permissions
- Runs pre-create hooks for modifications
- Processes presets from permissions
- Handles Many-to-One (M2O) relationships
- Handles Any-to-One (A2O) relationships
- Inserts the record into the database
- Processes One-to-Many (O2M) relationships
- 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 IDdate_created: Set to current timestamp- Default Values: Applied from field schema
Reading Items
Get All Items
Get Single Item
Query Parameters
Directus provides powerful query parameters for filtering, sorting, and pagination:Filtering
Field Selection
Sorting
- for descending order.
Pagination
Search
Updating Items
Update Single Item
Update Multiple Items
Update multiple items by their IDs:Auto-Updated Fields
user_updated: Set to the authenticated user’s IDdate_updated: Set to current timestamp
Deleting Items
Delete Single Item
Delete Multiple Items
Item Revisions
When revisions are enabled for a collection, Directus tracks every change to items:directus_revisions:
Item Activity
When accountability is enabled, all item actions are logged indirectus_activity:
create- Item creationupdate- Item modificationdelete- Item deletioncomment- Comments added to item
Nested Relational Data
Items can include related data from other collections through field expansion:Deep Nesting
Supports deep nesting of relationships:Creating Items with Relationships
Create related items inline during item creation:~/workspace/source/api/src/services/items.ts:203-216), relationship processing handles:
- M2O (Many-to-One): Creates related item first, uses returned ID
- A2O (Any-to-One): Similar to M2O with collection specification
- 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.
~/workspace/source/api/src/services/items.ts:89-104):
Singleton Items
For singleton collections, use a simplified API: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
Related Concepts
- Collections - Tables that contain items
- Fields - Attributes that define item structure
- Relationships - Links between items in different collections
- Permissions - Access control for item operations