workflow CLI command

Detailed information on the workflow CLI command

Manage Dapr workflow instances.

Commands

CommandDescription
dapr workflow runStart a new workflow instance
dapr workflow listList workflow instances
dapr workflow historyGet workflow execution history
dapr workflow purgePurge workflow instances
dapr workflow suspendSuspend a workflow
dapr workflow resumeResume a workflow
dapr workflow terminateTerminate a workflow
dapr workflow raise-eventRaise an external event
dapr workflow rerunRe-run a workflow

Flags

  -a, --app-id string      The app ID owner of the workflow instance
  -h, --help               help for workflow
  -k, --kubernetes         Target a Kubernetes dapr installation
  -n, --namespace string   Namespace to perform workflow operation on (default "default")

Examples

List workflows

dapr workflow list --app-id myapp

Start a workflow

dapr workflow run MyWorkflow --app-id myapp --input '{"key": "value"}'

Kubernetes mode

dapr workflow list -k -n production --app-id myapp

List workflow instances for a given application.

Usage

dapr workflow list [flags]

Flags

NameTypeDescription
--app-id, -astring(Required) The app ID owner of the workflow instances
--filter-name, -wstringFilter workflows by name
--filter-status, -sstringFilter by status: RUNNING, COMPLETED, FAILED, CANCELED, TERMINATED, PENDING, SUSPENDED
--filter-max-age, -mstringFilter workflows started within duration or timestamp (e.g., “300ms”, “1.5h”, “2023-01-02T15:04:05”)
--output, -ostringOutput format: short, wide, yaml, json (default “short”)
--connection-string, -cstringConnection string to the actor state store
--table-name, -tstringTable or collection name used as the actor state store
--kubernetes, -kboolTarget a Kubernetes Dapr installation
--namespace, -nstringKubernetes namespace (default “default”)

Examples

Basic usage

dapr workflow list --app-id myapp

Filter by status

dapr workflow list --app-id myapp --filter-status RUNNING

Filter by workflow name

dapr workflow list --app-id myapp --filter-name OrderProcessing

Filter by age

# Workflows from last 24 hours
dapr workflow list --app-id myapp --filter-max-age 24h

# Workflows after specific date
dapr workflow list --app-id myapp --filter-max-age 2024-01-01T00:00:00Z

JSON output

dapr workflow list --app-id myapp --output json

Kubernetes with port forwarding

# Terminal 1: Port forward to database
kubectl port-forward service/postgres 5432:5432 -n production

# Terminal 2: List workflows with direct database access
dapr workflow list \
  --kubernetes \
  --namespace production \
  --app-id myapp \
  --connection-string "host=localhost user=dapr password=dapr dbname=dapr port=5432 sslmode=disable" \
  --table-name workflows

Connection String Formats

PostgreSQL / CockroachDB

host=localhost user=dapr password=dapr dbname=dapr port=5432 sslmode=disable

MySQL

dapr:dapr@tcp(localhost:3306)/dapr?parseTime=true

SQL Server

sqlserver://dapr:Pass@word@localhost:1433?database=dapr

MongoDB

mongodb://localhost:27017/dapr

Redis

redis[s]://[[username][:password]@][host][:port][/db-number]:

Purge workflow instances with terminal states (COMPLETED, FAILED, TERMINATED).

Usage

dapr workflow purge [instance-id] [flags]

Flags

NameTypeDescription
--app-id, -astring(Required) The app ID owner of the workflow instances
--allboolPurge all terminal workflow instances (use with caution)
--all-older-thanstringPurge instances older than duration or timestamp (e.g., “24h”, “2023-01-02T15:04:05Z”)
--connection-string, -cstringConnection string to the actor state store
--table-name, -tstringTable or collection name used as the actor state store
--kubernetes, -kboolTarget a Kubernetes Dapr installation
--namespace, -nstringKubernetes namespace (default “default”)

Examples

Purge a specific instance

dapr workflow purge wf-12345 --app-id myapp

Purge instances older than 30 days

dapr workflow purge --app-id myapp --all-older-than 720h

Purge instances older than specific date

dapr workflow purge --app-id myapp --all-older-than 2023-12-01T00:00:00Z

Purge all terminal instances (dangerous!)

dapr workflow purge --app-id myapp --all

Kubernetes with database access

# Port forward to database
kubectl port-forward service/postgres 5432:5432 -n production

# Purge old workflows
dapr workflow purge \
  --kubernetes \
  --namespace production \
  --app-id myapp \
  --connection-string "host=localhost user=dapr password=dapr dbname=dapr port=5432 sslmode=disable" \
  --table-name workflows \
  --all-older-than 2160h  # 90 days

Best Practices

  1. Regular Cleanup: Schedule periodic purge operations

    # Cron job to purge workflows older than 90 days
    0 2 * * 0 dapr workflow purge --app-id myapp --all-older-than 2160h
    
  2. Test First: Use list command to see what will be purged

    dapr workflow list --app-id myapp --filter-status COMPLETED --filter-max-age 2160h
    
  3. Backup Before Bulk Purge: Export data before using --all

    dapr workflow list --app-id myapp --output json > backup.json
    
Last modified November 10, 2025: `$ dapr workflow` CLI docs (#4916) (a6014dc)