1. MooseStack
  2. Moose APIs
  3. Trigger APIs

On this page

OverviewBasic UsageUsing the Trigger API

Trigger APIs

Overview

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

Basic Usage

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"}
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;
FiveonefourFiveonefour
Fiveonefour Docs
MooseStackTemplates
Changelog
Source506
  • Overview
  • Quick Start
  • Templates / Examples
Fundamentals
  • Moose Runtime
  • MooseDev MCP
  • Data Modeling
MooseStack in your App
  • App / API frameworks
Modules
  • Moose OLAP
  • Moose Streaming
  • Moose Workflows
  • Moose APIs
    • Auth
    • Ingest New Data
    • Expose Analytics
    • Trigger Workflows
    • Client Libraries
    • OpenAPI SDK
    • Admin APIs
Deployment & Lifecycle
  • Moose Migrate
  • Moose Deploy
Reference
  • API Reference
  • Data Types
  • Table Engines
  • CLI
  • Configuration
  • Observability Metrics
  • Help
  • Changelog
Contribution
  • Documentation
  • Framework