Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/directus/directus/llms.txt

Use this file to discover all available pages before exploring further.

Operations are the building blocks of flows. You can create custom operations to extend automation capabilities.

Creating an Operation

npm init directus-extension
# Select "operation" as the extension type

Operation Structure

import { defineOperationApi } from '@directus/extensions-sdk';

export default defineOperationApi({
  id: 'my-operation',
  handler: async ({ data }, { services, getSchema }) => {
    const schema = await getSchema();
    const itemsService = new services.ItemsService('articles', { schema });

    // Perform your operation logic
    const result = await itemsService.readByQuery({
      filter: data.filter,
    });

    return result;
  },
});

App Component

Create a UI component for configuring the operation:
import { defineOperationApp } from '@directus/extensions-sdk';

export default defineOperationApp({
  id: 'my-operation',
  name: 'My Operation',
  icon: 'bolt',
  description: 'Custom operation',
  overview: ({ filter }) => [
    {
      label: 'Filter',
      text: JSON.stringify(filter),
    },
  ],
  options: [
    {
      field: 'filter',
      name: 'Filter',
      type: 'json',
      meta: {
        interface: 'input-code',
        options: {
          language: 'json',
        },
      },
    },
  ],
});

Built-in Operations

Directus includes operations for:
  • Item CRUD
  • HTTP requests
  • Email sending
  • Conditional logic
  • Data transformation
  • Logging
  • And more…

Next Steps

Hooks

Create server hooks

Endpoints

Create API endpoints