Skip to content

Executing Workflows

Learn how to run workflows and manage executions.

Execution Methods

Method Description
CLI Run from command line
API Execute via REST API
Webhook Trigger via HTTP request
Schedule Automatic cron-based

CLI Execution

Run from File

m9m run workflow.json

Run by ID

m9m run 550e8400-e29b-41d4-a716-446655440000

Run by Name

m9m run "Daily Report"

With Input Data

# Inline JSON
m9m run workflow.json --input '{"name": "John"}'

# From file
m9m run workflow.json --input @input.json

Raw Output

m9m run workflow.json --raw

API Execution

Synchronous

Wait for completion:

curl -X POST http://localhost:8080/api/v1/workflows/{id}/execute \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"inputData": [{"json": {"key": "value"}}]}'

Response:

{
  "id": "exec-123",
  "status": "success",
  "data": [{"json": {"result": "..."}}]
}

Asynchronous

Return immediately:

curl -X POST http://localhost:8080/api/v1/workflows/{id}/execute-async \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"inputData": [{"json": {"key": "value"}}]}'

Response:

{
  "jobId": "job-456",
  "status": "pending"
}

Then check status:

curl http://localhost:8080/api/v1/jobs/job-456

Webhook Execution

Configure a webhook node and call it:

curl -X POST http://localhost:8080/webhook/my-endpoint \
  -H "Content-Type: application/json" \
  -d '{"event": "user_signup", "data": {...}}'

Scheduled Execution

Workflows with Cron nodes run automatically:

{
  "type": "n8n-nodes-base.cron",
  "parameters": {
    "cronExpression": "0 9 * * MON-FRI"
  }
}

Manage via API:

# Create schedule
curl -X POST http://localhost:8080/api/v1/schedules \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "workflowId": "wf-123",
    "cronExpression": "0 9 * * *"
  }'

Execution Status

Status Description
pending Queued, waiting
running Currently executing
success Completed successfully
failed Completed with error
cancelled Manually stopped

Monitoring Executions

List Executions

m9m execution list

Or via API:

curl http://localhost:8080/api/v1/executions

Get Execution Details

m9m execution get exec-123

Watch in Real-Time

m9m execution watch

Handling Failures

View Error Details

m9m execution get exec-123

Shows:

Status: failed
Error:
  Node: HTTP Request
  Message: Connection timeout

Retry Failed Execution

m9m execution retry exec-123

Or via API:

curl -X POST http://localhost:8080/api/v1/executions/exec-123/retry

Cancel Running Execution

m9m execution cancel exec-123

Or via API:

curl -X POST http://localhost:8080/api/v1/executions/exec-123/cancel

Input Data

Structure

{
  "inputData": [
    {
      "json": {
        "field1": "value1",
        "field2": 123
      }
    }
  ]
}

Multiple Items

{
  "inputData": [
    {"json": {"id": 1}},
    {"json": {"id": 2}},
    {"json": {"id": 3}}
  ]
}

Access in Workflow

First node receives input data:

{{ $json.field1 }}  // "value1"

Execution Output

Success Output

{
  "id": "exec-123",
  "status": "success",
  "data": [
    {
      "json": {
        "result": "processed",
        "count": 5
      }
    }
  ],
  "duration": 1234
}

Failed Output

{
  "id": "exec-124",
  "status": "failed",
  "error": {
    "message": "HTTP request failed",
    "node": "Fetch Data"
  }
}

Best Practices

  1. Test with sample data before production
  2. Use async for long-running workflows
  3. Monitor failures and set up alerts
  4. Add timeouts for external calls
  5. Log important data for debugging