# Advanced

> Advanced guide for using Directus API features in Zapier, including raw request actions, advanced filtering, and custom API calls.

This guide covers advanced Directus features in Zapier, including raw request actions and advanced filtering in Find actions.

**← Back to Zapier Integration**

## Raw Request Actions

Raw Request actions provide full HTTP method control for Items, Users, and Files. These actions allow you to use Directus's native JSON syntax for filters, query parameters, and data manipulation.

## Available Raw Request Actions

Quick reference of all available raw request actions:

<table>
<thead>
  <tr>
    <th>
      Resource
    </th>
    
    <th>
      Operation
    </th>
    
    <th>
      HTTP Methods
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Items
      </strong>
    </td>
    
    <td>
      Raw Request
    </td>
    
    <td>
      POST, PATCH, DELETE
    </td>
    
    <td>
      Full HTTP method control for items
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Users
      </strong>
    </td>
    
    <td>
      Raw Request
    </td>
    
    <td>
      POST, PATCH, DELETE
    </td>
    
    <td>
      Full HTTP method control for users
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Files
      </strong>
    </td>
    
    <td>
      Raw Request
    </td>
    
    <td>
      PATCH, DELETE
    </td>
    
    <td>
      Full HTTP method control for files
    </td>
  </tr>
</tbody>
</table>

---

<callout icon="i-lucide-lightbulb">

**When to Use Raw Request Actions**
Use raw request actions when you need full control over HTTP methods, complex query parameters (aggregation, search, etc.), or complete control over the JSON payload structure. For advanced filtering in Find actions, use the Filter (JSON) field instead.

</callout>

## Using Raw Request Actions

Raw Request actions allow you to make custom Directus API calls with full control over the HTTP method and request body.

### Setting Up a Raw Request Action

1. Add **Directus** as an action step
2. Select **Raw Request** operation (Items, Users, or Files)
3. Choose the **HTTP Method** (POST, PATCH, or DELETE)
4. For Items, select the **Collection**
5. Configure the request:

  - **Item/User/File**: Select from dropdown (required for PATCH only)
  - **Request Body (JSON)**: JSON data for POST/PATCH requests
  - **Filter (JSON)**: Filter conditions (required for DELETE operations)

<callout icon="i-lucide-triangle-alert" color="warning">

**Token Permissions**
Ensure your Directus API token has the correct permissions for the resource and operations you're using. Raw request actions require the same permissions as their standard counterparts.

</callout>

### Items - Raw Request

**POST** - Create items with full JSON control:

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

**PATCH** - Update items with complex data structures:

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

**DELETE** - Delete items by ID or using Filter (JSON) for bulk deletion

### Users - Raw Request

**POST** - Create users with full JSON control:

```json
{
  "email": "user@example.com",
  "first_name": "John",
  "last_name": "Doe",
  "role": "role-uuid-here"
}
```

**PATCH** - Update users with complex data structures:

```json
{
  "status": "suspended",
  "metadata": {
    "reason": "Account violation"
  }
}
```

**DELETE** - Delete users by ID or using Filter (JSON) for bulk deletion

### Files - Raw Request

**PATCH** - Update file metadata with complex data structures:

```json
{
  "title": "Updated Title",
  "description": "New description",
  "tags": ["tag1", "tag2"]
}
```

**DELETE** - Delete files by ID or using Filter (JSON) for bulk deletion

## Working with Relations

When using **Raw Request** actions or creating items with relations:

**Many-to-One:**

```json
{
  "title": "My Post",
  "author": "author-uuid-here"
}
```

**Many-to-Many:**

```json
{
  "title": "My Post",
  "categories": ["category-uuid-1", "category-uuid-2"]
}
```

**One-to-Many:**

```json
{
  "title": "My Post",
  "comments": [{ "text": "Great post!", "user": "user-uuid-here" }]
}
```

## Advanced Tips

### Using Dynamic Values in Filters

You can use data from previous steps in your filters by using Zapier's field mapping in the filter fields.

### Batch Processing

For bulk operations:

1. Use **Find** to get all items
2. Enable **"Return all results as line items"**
3. Add a **Filter** step if needed
4. Add **Update Item** to process each item

## Performance Tips

- **Select only needed fields**: Use field mapping to reduce data transfer
- **Use pagination**: Use the **Limit** field in search actions, process in batches
- **Filter in Directus**: Always use Directus filters rather than Filter steps when possible

**Example:**

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

Whether to filter on `status` or `archived` depends on your collection's schema. Collections created in Directus v12 may use the boolean `archived` field instead of a string `status` field.

---

## Next Steps

- **← Back to Integration** Return to the integration overview
- **Learn about Actions →** Basic operations guide
- **Learn about Triggers →** Automation workflows

## Additional Resources

- [Directus Filter Rules](https://directus.com/docs/guides/connect/filter-rules) - Complete filter syntax and operators
- [Directus Query Parameters](https://directus.com/docs/guides/connect/query-parameters) - All available query parameters
