Selegic CRM Docs
ServerFlows

API Reference

Execution endpoints, replay API, and internal service usage.

Execution API

Flows are exposed via Hono routes in flow.handler.ts.

Execute Flow

POST /api/v1/flows/:id/execute

Request:

{
  "event": {
    "userId": "user_123",
    "action": "signup",
    "recordId": "contact_456"
  },
  "idempotencyKey": "unique-request-id"
}

Response:

{
  "executionId": "run_abc",
  "status": "COMPLETED",
  "outputs": {
    "result": "..."
  },
  "duration": 1250
}

Get Execution Status

GET /api/v1/executions/:executionId

List Executions

GET /api/v1/flows/:flowId/executions

Replay API

Restart a previous execution from the beginning:

POST /api/v1/executions/:executionId/replay

Uses the exact same version and initial event data.

Node Debug API

Get detailed node-level information:

GET /api/v1/executions/:executionId/nodes/:nodeId

Response includes:

  • Input variables
  • Output results
  • Error messages (if failed)
  • Execution timestamps

Internal Service Usage

For backend services, use the Effect-TS service directly instead of HTTP:

import { FlowExecutionEngine } from "./flow-execution.engine";

const program = Effect.flatMap(
  FlowExecutionEngine,
  engine => engine.execute({
    flowId: "flow_123",
    event: { userId: "user_456" },
  })
);

const result = await Effect.runPromise(
  program.pipe(Effect.provide(FlowExecutionEngineLive))
);

Execute with Context

const result = await Effect.runPromise(
  FlowExecutionEngine.execute({
    flowId: "flow_123",
    event: { 
      recordId: "contact_789",
      action: "created" 
    },
    context: {
      orgId: "org_abc",
      userId: "user_123",
    },
  }).pipe(Effect.provide(FlowExecutionEngineLive))
);

Error Responses

CodeDescription
404Flow not found
409Idempotency key conflict
422Flow not active
429Rate limit exceeded
500Engine error

On this page