Advanced

Advanced guide for using Directus raw CRUD operations in n8n, including raw JSON operations, complex filters, relational queries, and query parameters.

This guide covers advanced Directus features in n8n using raw CRUD operations, which give you full access to Directus's native filter syntax, query parameters, and complex query capabilities.

← Back to Directus + n8n Overview

Raw CRUD Operations

The Directus node provides raw versions of all CRUD operations that allow you to use Directus's native JSON syntax for filters, query parameters, and data manipulation. These operations give you full control over the API request.

Available Raw Operations

Quick reference of all available raw operations organized by resource type:

ResourceOperationDescription
ItemsCreate (Raw JSON)Create items with full JSON control
ItemsGet (Raw JSON)Retrieve a single item with custom query parameters
ItemsGet Many (Raw JSON)Retrieve multiple items with advanced filters and query parameters
ItemsUpdate (Raw JSON)Update items with complex data structures
UsersGet (Raw JSON)Retrieve a single user with custom query parameters
UsersGet Many (Raw JSON)Retrieve multiple users with advanced filters and query parameters
UsersUpdate (Raw JSON)Update users with complex data structures
FilesGet (Raw JSON)Retrieve a single file with custom query parameters
FilesGet Many (Raw JSON)Retrieve multiple files with advanced filters and query parameters
FilesUpdate (Raw JSON)Update files with complex data structures

When to Use Raw Operations Use raw operations when you need complex filters with logical operators (_and, _or), relational field filtering, advanced query parameters (aggregation, search, etc.), reading a specific content version (draft or published), or full control over the JSON payload structure.

Using Raw Operations

Raw operations work similarly to their standard counterparts, but instead of using the node's form fields, you provide data as a JSON object: the JSON Data field for Create/Update, or the Query Parameters field for Get/Get Many.

Setting Up a Raw Operation

  1. Add a Directus node to your workflow
  2. Set Resource to Item, User, or File
  3. Select a Raw JSON operation (e.g., "Get Many (Raw JSON)", "Create (Raw JSON)")
  4. For Items operations, select the Collection
  5. Enter your data in the JSON Data field (Create/Update) or the Query Parameters field (Get/Get Many)
  6. For Get and Update operations, provide the Item ID if needed
Token Permissions Ensure your Directus API token has the correct permissions for the resource and operations you're using. Raw operations require the same permissions as their standard counterparts.

Get Many (Raw JSON)

Retrieve items with advanced filtering and query parameters:

{
  "filter": {
    "status": {"_eq": "published"},
    "views": {"_gt": 1000}
  },
  "fields": "title,author.name,views",
  "sort": "-date_created",
  "limit": 10
}

Get (Raw JSON)

Retrieve a single item with custom query parameters:

{
  "fields": "title,content,author.name,author.email,comments.text"
}

Create (Raw JSON)

Create items with full control over the JSON structure:

{
  "title": "My New Post",
  "content": "Post content here",
  "status": "published",
  "author": "author-uuid-here",
  "categories": ["category-uuid-1", "category-uuid-2"]
}

Update (Raw JSON)

Update items with complex data structures:

{
  "title": "Updated Title",
  "status": "archived",
  "metadata": {
    "tags": ["updated", "archived"],
    "notes": "Item has been archived"
  }
}

Using Filters with Raw Operations

Raw operations allow you to use Directus's complete filter syntax. Specify filters in the filter parameter of the Query Parameters field (Get Many).

Filter Documentation For complete filter syntax, operators, and examples, see the Directus Filter Rules documentation.

Example: Complex filter with logical operators

{
  "filter": {
    "_and": [
      {"status": {"_eq": "published"}},
      {
        "_or": [
          {"category": {"_eq": "tutorial"}},
          {"category": {"_eq": "guide"}}
        ]
      },
      {"views": {"_gt": 100}}
    ]
  }
}

Example: Relational filtering

{
  "filter": {
    "author": {
      "name": {"_eq": "John Doe"}
    },
    "comments": {
      "_some": {
        "status": {"_eq": "approved"}
      }
    }
  }
}

Query Parameters

Get (Raw JSON) and Get Many (Raw JSON) support all Directus query parameters. Include them in the Query Parameters field alongside filters:

Common query parameters:

{
  "fields": "title,author.name,views",
  "sort": "-date_created",
  "limit": 10,
  "offset": 0
}

Search:

{
  "search": "directus tutorial"
}

Aggregation:

{
  "aggregate": {
    "count": "id",
    "sum": "views",
    "avg": "rating"
  },
  "groupBy": "category"
}
Query Parameters Documentation For complete query parameter documentation, see the Directus Query Parameters documentation.

Content Versioning

When it applies

Only collections with content versioning enabled in Directus use the version query parameter. Non-versioned collections don't need it.

Only use version on versioned collections Don't add it to every request by default. It's only relevant when content versioning is enabled for that collection.

Reading versioned content

Use Get (Raw JSON) and pass version in the Query Parameters field. The version parameter only applies to single-item retrieval, so it has no effect on Get Many (Raw JSON):

{
  "version": "draft"
}

Or for the published version:

{
  "version": "published"
}

version: "main" still works for backward compatibility, but published is preferred. See Directus v12 breaking changes.

Updating draft content

Directus doesn't accept a version parameter on item updates. Draft edits go through the dedicated Versions API instead: POST /versions/{id}/save to save changes to a version, then POST /versions/{id}/promote to publish it.

Neither Update nor Update (Raw JSON) can call these endpoints. Use an HTTP Request node to call them directly with your Directus credentials.

See Content Versioning for the full versioning workflow in Directus.

Working with Relations

When using Create (Raw JSON) or Update (Raw JSON), you can include related data directly in your JSON:

{
  "title": "My Post",
  "author": "author-uuid-here",
  "categories": ["category-uuid-1", "category-uuid-2"],
  "comments": [
    {"text": "Great post!", "user": "user-uuid-here"}
  ]
}

Using Expressions in Raw Operations

You can use n8n expressions in your raw JSON data for dynamic queries:

{
  "filter": {
    "status": {"_eq": "{{ $json.status }}"},
    "views": {"_gt": {{ $json.min_views }}}
  },
  "fields": "{{ $json.requested_fields }}",
  "sort": "-{{ $json.sort_field }}",
  "limit": {{ $json.limit }}
}

Performance Tips

  • Select only needed fields: Use the fields parameter to reduce data transfer
  • Use pagination: Use limit and offset/page for large datasets, process in batches with n8n's Split In Batches node
  • Filter in Directus: Always use the filter parameter rather than processing all data in n8n

Example:

{
  "fields": "id,title,status",
  "filter": {
    "status": {"_eq": "published"},
    "date_created": {"_gte": "$NOW(-30 days)"}
  },
  "limit": 100
}

Next Steps

Get once-a-month release notes & real‑world code tips...no fluff. 🐰