Skip to main content
Directus webhooks allow you to create HTTP endpoints that trigger workflows, enabling integration with external systems and automation of tasks via HTTP requests.

Overview

Webhooks in Directus are implemented through the Flows system using webhook triggers. This provides a powerful way to create custom API endpoints that execute automated workflows.
Webhooks in Directus are part of the Flows automation system. For more details on flows, see Flows & Automation.

Creating Webhook Flows

A webhook flow consists of a trigger and operations:

Webhook Trigger Options

HTTP Method

Specify which HTTP method triggers the flow:

Async Execution

Control whether the webhook waits for completion:
  • async: false - HTTP request waits for flow completion, returns result
  • async: true - Returns immediately, flow executes in background

Return Value

Specify what data to return in the HTTP response:

Webhook URL

Once created, webhook flows are accessible at:
The flow ID is a UUID automatically assigned when the flow is created.

Accessing Webhook Data

Webhook payload is available in operations via $trigger:

Webhook Context

Additional context available:
  • {{$trigger.body}} - Request body (JSON)
  • {{$trigger.query}} - Query parameters
  • {{$trigger.headers}} - HTTP headers
  • {{$accountability.user}} - Authenticated user (if token provided)
  • {{$accountability.role}} - User’s role
  • {{$accountability.ip}} - Request IP address

Authentication

Webhooks can be authenticated using access tokens:

Public Webhooks

To create a public webhook (no authentication required):
  1. Create the flow with webhook trigger
  2. Set permissions for the Public role
  3. Allow access to the flow
Public webhooks should validate input carefully and implement rate limiting to prevent abuse.

Example Workflows

Simple Data Ingestion

Receive data from external service:
Call the webhook:

Conditional Processing

Process different data types:

External API Integration

Receive webhook, process, and call external API:

Validation and Error Handling

Validate input and handle errors:

GET Webhooks with Caching

For GET webhooks, enable caching:

Response Format

Successful Response

Error Response

Query Parameters

Access query parameters in operations:

Headers

Access request headers:

Rate Limiting

Implement rate limiting for webhooks:

Webhook Logs

Log all webhook calls for debugging:

Best Practices

Always validate webhook input using condition operations before processing data.
Set async: true for webhooks that trigger long-running operations to avoid timeouts.
Use Bearer tokens or API keys to secure webhooks. Don’t rely on obscurity alone.
Keep logs of webhook calls for debugging and audit purposes.
Use condition operations to detect errors and return appropriate error messages.
Implement rate limiting to prevent abuse of public webhook endpoints.