content/guides/12.integrations/2.clay/use-clay-templates-with-directus.md
Clay provides pre-built templates for common operations with Directus. These templates appear as enrichment column options and handle all the API configuration for you.
← Back to Directus + Clay Overview
Follow these steps to use the pre-built Directus templates in Clay.
Before using any templates, configure your Directus authentication in Clay:
AuthorizationBearer YOUR_DIRECTUS_TOKEN_HERE💡 Tip: Once created, you can select this account for all Directus API calls instead of manually entering headers each time.
| Template | Purpose |
|---|---|
| Create Item in Collection | Add new records to Directus |
| Update Item in Collection | Modify existing records in Directus |
| Get Item from Collection | Search and retrieve records from Directus |
| Get Related Item Details | Fetch relational data from Directus |
::callout{icon="material-symbols:warning" color="warning"}
Important
The Directus templates use generic collection names (like "posts" or "users") as examples. You'll need to adapt these to match your specific Directus schema by replacing collection names, adjusting field names, and configuring filters based on your data structure.
::
Each template requires configuration specific to your Directus setup:
Basic Configuration:
| Setting | Description |
|---|---|
| Directus URL | Your instance URL (e.g., https://your-project.directus.app) |
| Collection Name | Replace "posts" with your actual collection name |
| Account | Select the "Directus" account you created in Step 1 |
For GET operations, add query parameters:
::field{name="limit" type="number"}
Maximum number of items to return (e.g., 10)
::
::field{name="fields" type="string"}
Comma-separated field names (e.g., id,title,status)
::
::field{name="filter[field][operator]" type="string"}
Filter criteria (e.g., filter[status][_eq] with value published)
::
For more advanced filtering options and field selection techniques, see the Working with Directus Data Operations guide.
For POST/PATCH operations, configure the body:
Configure how Clay data maps to Directus fields:
status: "draft")Example mapping for creating a blog post:
{
"title": "{{Blog Post Title Column}}",
"slug": "{{URL Slug Column}}",
"content": "{{Post Content Column}}",
"status": "draft",
"author": "{{Author ID Column}}"
}
💡 Tip: Use Clay's visual field mapper for easier configuration, or write JSON directly for more control.