1. MooseStack
  2. Moose APIs & Web Apps
  3. Trigger APIs

Trigger APIs

Overview

You can create APIs to initiate workflows, data processing jobs, or other automated processes.

Basic Usage

app/apis/trigger_workflow.ts
import { Api } from "@514labs/moose-lib"; interface WorkflowParams {  inputValue: string;  priority?: string;} interface WorkflowResponse {  workflowId: string;  status: string;} const triggerApi = new Api<WorkflowParams, WorkflowResponse>(  "trigger-workflow",  async ({ inputValue, priority = "normal" }: WorkflowParams, { client }) => {    // Trigger the workflow with input parameters    const workflowExecution = await client.workflow.execute("data-processing", {         inputValue,        priority,        triggeredAt: new Date().toISOString()      }    );     return {      workflowId: workflowExecution.id,      status: "started"    };  }); export default triggerApi;

Using the Trigger API

Once deployed, you can trigger workflows via HTTP requests:

curl "http://localhost:4000/api/trigger-workflow?inputValue=process-user-data&priority=high"

Response:

{  "workflowId": "workflow-12345",  "status": "started"}

On this page

OverviewBasic UsageUsing the Trigger API
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
  • Moose APIs & Web Apps
    • Native APIs
    • Ingest API
    • Analytics API
    • Workflow Trigger
    • Admin APIs
    • Authentication
    • Use Your Web Framework
    • Overview
    • Express
    • Fastify
    • Koa
    • Raw Node.js
Deployment & Lifecycle
  • Moose Migrate
  • Moose Deploy
Reference
  • API Reference
  • Data Types
  • Table Engines
  • CLI
  • Configuration
  • Observability Metrics
  • Help
  • Release Notes
Contribution
  • Documentation
  • Framework
app/apis/trigger_workflow.ts
import { Api } from "@514labs/moose-lib"; interface WorkflowParams {  inputValue: string;  priority?: string;} interface WorkflowResponse {  workflowId: string;  status: string;} const triggerApi = new Api<WorkflowParams, WorkflowResponse>(  "trigger-workflow",  async ({ inputValue, priority = "normal" }: WorkflowParams, { client }) => {    // Trigger the workflow with input parameters    const workflowExecution = await client.workflow.execute("data-processing", {         inputValue,        priority,        triggeredAt: new Date().toISOString()      }    );     return {      workflowId: workflowExecution.id,      status: "started"    };  }); export default triggerApi;