These docs cover the S6S workflow engine — the developer playground layer underneath the product. For the main AI Visibility product (brand monitoring, the unified Report, fix actions), start at /docs/ai-visibility.

TypeScript SDK

Deploy, run, and manage workflows programmatically with a fluent builder API.

Installation

npm install @s6s/sdk

Quick Start

Create a client, build a workflow with WorkflowBuilder, and deploy it in a single call.

TypeScript
import { S6SClient, WorkflowBuilder } from "@s6s/sdk";

const client = new S6SClient({
  baseUrl: "https://s6s.ai",
  apiKey: "s6s_your_key_here",
});

// Build a workflow with the fluent builder
const workflow = new WorkflowBuilder("Data Pipeline")
  .schedule("*/15 * * * *")
  .httpGet("Fetch Data", "https://api.example.com/data")
  .transform("Shape Output", {
    count: "{{steps.PREV.output.body.length}}",
  })
  .code("Process", "return { total: steps.PREV?.output?.count ?? 0 };")
  .build();

// Deploy and run
const result = await client.deployWorkflow(workflow);
console.log(result.workflowId, result.runId);

// Wait for the run to complete
const run = await client.waitForRun(result.runId!);
console.log(run.run.status); // "succeeded" | "failed"

S6SClient API

Create a client with new S6SClient({ baseUrl, apiKey }). All methods return promises.

MethodDescription
deployWorkflow(json, opts?)Deploy a workflow from IR JSON. Returns workflowId, runId, monitorUrl.
validateDeployedWorkflow(id)Server-side pre-flight check (credentials, config, schedule).
runWorkflow(id)Manually trigger a run for a deployed workflow.
getRunStatus(runId)Get run status, summary, and step details.
waitForRun(runId, opts?)Poll until a run reaches a terminal state.
streamRun(runId)Stream run events via Server-Sent Events.
listWorkflows()List all deployed workflows.
listRuns(opts?)List runs with optional status filter and limit.
cancelRun(runId)Cancel a running workflow.
retryFailed(runId)Retry a failed run.
getNodeTypes(opts?)Get the available node type catalog.
dryRun(json)Validate a workflow without executing it.
validateWorkflow(json)Client-side IR schema validation (no network call).

WorkflowBuilder

The builder provides a fluent interface with auto-chaining — each node automatically connects to the previous one. Call .build() at the end to produce IR JSON ready for deployWorkflow().

MethodNode Type
.webhook(path, method?)trigger.webhook
.schedule(cron, timezone?)trigger.schedule
.http(name, url, method?, opts?)action.http
.httpGet(name, url, opts?)action.http (GET)
.httpPost(name, url, opts?)action.http (POST)
.transform(name, template)action.transform
.code(name, expression)action.code
.slack(name, channel, text, cred)action.slack
.email(name, to, subject, body, cred)action.email
.database(name, query, opts?)action.database
.filter(name, array, condition, mode?)action.filter
.condition(name, expr, operator, value)logic.condition
.wait(name, seconds)logic.wait
.edge(sourceId, targetId, cond?)Custom edge
.onError(targetId)Error fallback edge

Examples

Deploy and wait for result

TypeScript
import { S6SClient, WorkflowBuilder } from "@s6s/sdk";

const client = new S6SClient({
  baseUrl: "https://s6s.ai",
  apiKey: process.env.S6S_API_KEY!,
});

const workflow = new WorkflowBuilder("Health Check")
  .schedule("0 * * * *")
  .httpGet("Ping", "https://example.com/health")
  .transform("Format", {
    status: "{{steps.PREV.output.body.status}}",
    checkedAt: "{{run.startedAt}}",
  })
  .build();

const { workflowId, runId } = await client.deployWorkflow(workflow);
console.log("Deployed:", workflowId);

if (runId) {
  const result = await client.waitForRun(runId);
  console.log("Status:", result.run.status);
}

Webhook trigger with parallel branches and error handling

TypeScript
const workflow = new WorkflowBuilder("Order Processor")
  .webhook("/orders/new", "POST")
  .transform("Extract", {
    orderId: "{{trigger.output.body.order_id}}",
    email: "{{trigger.output.body.customer_email}}",
  })
  .slack("Notify Team", "#orders",
    "New order #{{steps.Extract.output.orderId}}",
    "slack-credential-id"
  )
  .email("Confirm Customer",
    "{{steps.Extract.output.email}}",
    "Order Received",
    "Thanks for your order #{{steps.Extract.output.orderId}}!",
    "email-credential-id"
  )
  .onError("Notify Team") // fallback to Slack on failure
  .build();

const result = await client.deployWorkflow(workflow);
console.log("Webhook URL:", result.webhookTrigger?.invokeUrl);

List and manage workflows

TypeScript
// List all workflows
const workflows = await client.listWorkflows();
for (const wf of workflows) {
  console.log(wf.id, wf.name, wf.enabled);
}

// List recent failed runs
const failedRuns = await client.listRuns({
  status: "failed",
  limit: 5,
});

// Retry a failed run
if (failedRuns.length > 0) {
  const retried = await client.retryFailed(failedRuns[0].id);
  console.log("Retried:", retried.runId);
}

// Cancel a running workflow
const activeRuns = await client.listRuns({ status: "running" });
if (activeRuns.length > 0) {
  await client.cancelRun(activeRuns[0].id);
  console.log("Cancelled:", activeRuns[0].id);
}

Start building with the SDK

Install the package and deploy your first workflow in under a minute.