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.
| Endpoint | Description |
|---|---|
POST /admin/workflows/{workflowName}/trigger | Start a workflow |
POST /admin/workflows/{workflowName}/terminate | Stop a running workflow |
GET /admin/workflows/history | List 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:
[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
}'{ "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>'