1. MooseStack
  2. Moose Workflows
  3. Trigger Workflows

Trigger Workflows

Overview

Moose workflows can be triggered programmatically from various sources including APIs, events, external systems, or manual execution. This enables you to build reactive data processing pipelines and on-demand task execution.

Manual Workflow Execution

The simplest way to trigger a workflow is using the Moose CLI:

# Run a workflow manually
moose workflow run example
 
# Run with input parameters
moose workflow run example --input '{"name": "John", "email": "john@example.com"}'

Passing Input to Workflows

When triggering workflows, you can pass input data that will be passed to the starting task:

moose workflow run data-processing --input '{
  "sourceUrl": "https://api.example.com/data",
  "batchSize": 100
}'

The input is parsed as JSON and passed to the workflow's starting task.

API-Triggered Workflows

Trigger workflows directly via HTTP endpoints exposed by the webserver. These endpoints are protected by admin authentication.

EndpointDescription
POST /admin/workflows/{workflowName}/triggerStart a workflow
POST /admin/workflows/{workflowName}/terminateStop a running workflow
GET /admin/workflows/historyList workflow executions

Authentication

Workflow API endpoints require admin authentication in both development and production. If the admin API key is not configured, the endpoint returns 401 Unauthorized: Admin API key not configured.

Generate credentials using the CLI:

moose generate hash-token
# Output:
# ENV API Key: <hash>   ← store in config (safe to commit)
# Bearer Token: <token> ← use in requests (keep secret)

Add the ENV API Key value to moose.config.toml:

moose.config.toml
[authentication]admin_api_key = "<your-env-api-key>"

Use the Bearer Token value in your requests. For more details, see the API Authentication docs.

Trigger Request

curl -X POST 'http://localhost:4000/admin/workflows/data-processing/trigger' \
  -H 'Authorization: Bearer <your-bearer-token>' \
  -H 'Content-Type: application/json' \
  -d '{
    "sourceUrl": "https://api.example.com/data",
    "batchSize": 100
  }'
Response
{  "workflowId": "data-processing-<hash>",  "runId": "<id>",  "dashboardUrl": "..."  // included in dev only}

Terminate Request

curl -X POST 'http://localhost:4000/admin/workflows/data-processing/terminate' \
  -H 'Authorization: Bearer <your-bearer-token>'

History Request

curl -X GET 'http://localhost:4000/admin/workflows/history' \
  -H 'Authorization: Bearer <your-bearer-token>'

With optional query parameters:

curl -X GET 'http://localhost:4000/admin/workflows/history?status=RUNNING&limit=20' \
  -H 'Authorization: Bearer <your-bearer-token>'

On this page

OverviewManual Workflow ExecutionPassing Input to WorkflowsAPI-Triggered WorkflowsAuthenticationTrigger RequestTerminate RequestHistory Request
FiveonefourFiveonefour
Fiveonefour Docs
MooseStackTemplatesGuides
Release Notes
Source523
  • Overview
Build a New App
  • 5 Minute Quickstart
  • Browse Templates
  • Existing ClickHouse
Add to Existing App
  • Next.js
  • Fastify
Fundamentals
  • Moose Runtime
  • MooseDev MCP
  • Data Modeling
Moose Modules
  • Moose OLAP
  • Moose Streaming
  • Moose Workflows
    • Define Workflows
    • Scheduling
    • Triggers
    • Retries and Timeouts
    • Cancelling Running Workflows
  • Moose APIs & Web Apps
Deployment & Lifecycle
  • Moose Migrate
  • Moose Deploy
Reference
  • API Reference
  • Data Types
  • Table Engines
  • CLI
  • Configuration
  • Observability Metrics
  • Help
  • Release Notes
Contribution
  • Documentation
  • Framework