# FlowDrop Workflow

> Config entity for storing and managing workflow definitions with visual editor integration and REST API access.

## Overview

The `flowdrop_workflow` module provides the central workflow entity — a config entity that stores the complete workflow definition including nodes, edges, and metadata. It integrates with the FlowDrop visual editor for drag-and-drop workflow building and exposes REST API endpoints for programmatic workflow management.

Workflows are the primary unit of configuration in FlowDrop. Once defined, they can be executed by [flowdrop_runtime](flowdrop_runtime.md), triggered by events via [flowdrop_trigger](flowdrop_trigger.md), or tested interactively in the [flowdrop_playground](flowdrop_playground.md).

## Dependencies

- [flowdrop](flowdrop.md)
- [flowdrop_node_type](flowdrop_node_type.md) (node type definitions used within workflows)
- [flowdrop_node_category](flowdrop_node_category.md) (categories shown in the editor palette)

## Configuration

### Admin Pages

| Path | Description |
|------|-------------|
| `/admin/flowdrop/workflows` | List all workflows |
| `/admin/flowdrop/workflows/add` | Create a new workflow |
| `/admin/flowdrop/workflows/{id}/edit` | Edit workflow metadata (name, description) |
| `/admin/flowdrop/workflows/{id}/delete` | Delete a workflow |
| `/admin/flowdrop/workflows/{id}/editor` | Open the visual workflow editor |

### Permissions

| Permission | Description |
|------------|-------------|
| `administer flowdrop_workflow` | Full CRUD access to workflow definitions |

## Tips and Tricks

### Visual Editor

The workflow editor at `/admin/flowdrop/workflows/{id}/editor` provides a full drag-and-drop interface for building workflows. It loads node types from the [flowdrop_node_type](flowdrop_node_type.md) API and saves workflow definitions back through the workflow API.

### Workflow as Config Entity

Workflows are config entities, which means they can be exported and imported using Drupal's standard configuration management (`drush cex` / `drush cim`). This makes it straightforward to deploy workflows across environments.

### Workflow Execution

Workflows themselves are just definitions — they don't execute on their own. Execution is handled by:

- **[flowdrop_runtime](flowdrop_runtime.md)** — the execution engine that processes workflow definitions
- **[flowdrop_pipeline](flowdrop_pipeline.md)** — creates execution pipelines from workflow definitions
- **[flowdrop_trigger](flowdrop_trigger.md)** — automatically executes workflows in response to Drupal events

## Developer API

> All PHP classes in this module are `@internal` and not part of the stable public API. They may change without notice in any release. See the [BC Policy](../reference/api/bc-policy.md) for details.

### Entities

#### FlowDropWorkflow (Config Entity)

**Core Properties:**

| Property | Type | Description |
|----------|------|-------------|
| `id` | string | Unique workflow identifier |
| `label` | string | Human-readable name |
| `description` | string | Workflow description |
| `status` | boolean | Whether the workflow is enabled |
| `nodes` | array | Workflow node definitions with configurations |
| `edges` | array | Connections between nodes |
| `metadata` | array | Additional workflow metadata and settings |

### API Endpoints

| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/flowdrop/workflows` | List all workflows |
| POST | `/api/flowdrop/workflows` | Create a workflow |
| GET | `/api/flowdrop/workflows/{id}` | Get a workflow definition |
| PUT | `/api/flowdrop/workflows/{id}` | Update a workflow |
| DELETE | `/api/flowdrop/workflows/{id}` | Delete a workflow |
| POST | `/api/flowdrop/workflows/{id}/execute` | Execute a workflow |
| GET | `/api/flowdrop/workflows/{id}/executions/{execution_id}/state` | Get execution state |
| GET | `/api/flowdrop/executions/active` | List active executions |

## References

- [flowdrop_pipeline](flowdrop_pipeline.md) — creates execution pipelines from workflows
- [flowdrop_runtime](flowdrop_runtime.md) — executes workflows
- [flowdrop_trigger](flowdrop_trigger.md) — event-driven workflow execution
- [flowdrop_playground](flowdrop_playground.md) — interactive workflow testing
- [Creating Workflows](../guide/workflows/creating-workflows.md)
- [The Visual Editor](../guide/workflows/visual-editor.md)
