# Creating and Managing Workflows

Workflows are the core of FlowDrop. This guide covers how to create, edit, and manage workflows through the Drupal admin interface.

## Accessing the Workflow List

Navigate to **Administration > FlowDrop > Workflows** (`/admin/flowdrop/workflows`).

This page shows all existing workflows with their label, status, and available actions.

![Workflow listing page](../../screenshots/workflow-listing.png)

## Creating a Workflow

1. Click **+ Add Workflow**.
2. Fill in the form:
   - **Label** (required) — A human-readable name for the workflow.
   - **Description** (optional) — Notes about what the workflow does.
3. Click **Save**.

![Add Workflow form](../../screenshots/add-workflow-form.png)

The workflow is now created and ready to be edited in the visual editor.

## Opening the Visual Editor

From the workflow listing, click the dropdown on a workflow row and select **Open in Editor**. This opens the drag-and-drop visual editor where you build your workflow.

The editor URL follows the pattern: `/admin/structure/flowdrop-workflow/{id}/flowdrop-editor`

For a detailed guide on using the editor, see the [Visual Editor](visual-editor.md) page.

## Editing Workflow Metadata

To change the label or description of an existing workflow:

1. From the workflow listing, click **Edit** on the workflow row.
2. Modify the label, description, or status.
3. Click **Save**.

![Edit workflow form](../../screenshots/edit-workflow-form.png)

## Workflow Properties

| Property | Description |
|----------|-------------|
| **Label** | Human-readable name displayed in listings and the editor |
| **Description** | Optional notes about the workflow's purpose |
| **Status** | Enabled or disabled — disabled workflows cannot be executed or triggered |
| **Nodes** | Array of node definitions (managed via the visual editor) |
| **Edges** | Array of connections between nodes (managed via the visual editor) |

## Deleting a Workflow

1. From the workflow listing, click the dropdown and select **Delete**.
2. Confirm the deletion.

!!! warning
    Deleting a workflow also removes any associated trigger configurations. Existing pipeline history (past execution records) is retained but will reference a deleted workflow.

## Workflow Actions

The operations dropdown on each workflow row provides quick access to common actions:

![Workflow action dropdown](../../screenshots/workflow-actions-dropdown.png)

| Action | Description |
|--------|-------------|
| **Edit** | Modify label, description, and status |
| **Open in Editor** | Open the visual drag-and-drop editor |
| **Playground** | Open the interactive testing interface (requires `flowdrop_playground` module) |
| **Delete** | Permanently remove the workflow |

## Importing and Exporting Workflows

Workflows are stored as Drupal configuration entities, which means they can be exported, imported, and version-controlled using Drupal's standard configuration management system.

### Exporting a Workflow

Use Drush to export workflow configuration:

```bash
# Export all site configuration (includes workflows)
drush config:export

# Export a single workflow
drush config:get flowdrop_workflow.flowdrop_workflow.{workflow_id}
```

Exported workflows are stored as YAML files in your site's config sync directory (typically `sites/default/files/config_*/sync/`).

### Importing a Workflow

```bash
# Import all site configuration (includes workflows)
drush config:import

# Import a single workflow from a YAML file
drush config:set flowdrop_workflow.flowdrop_workflow.{workflow_id} --input-format=yaml < workflow.yml
```

### Moving Workflows Between Environments

To move workflows from development to staging or production:

1. Export configuration on the source environment: `drush config:export`
2. Transfer the config sync directory to the target environment (e.g., via Git).
3. Import configuration on the target environment: `drush config:import`

!!! tip
    Include your config sync directory in version control. This lets you track workflow changes alongside your codebase and deploy them through your standard CI/CD pipeline.

## Permissions

| Permission | What it allows |
|------------|---------------|
| `administer flowdrop` | Full access to create, edit, delete, and execute workflows |

## Next Steps

- **[Visual Editor](visual-editor.md)** — Learn to build workflows with the drag-and-drop editor
- **[Connecting Nodes](connecting-nodes.md)** — Understand ports, edges, and data flow
- **[Troubleshooting](../troubleshooting.md)** — Common issues and solutions
