Intermediate30 minModule 5 of 6

API & Automation

Use the Orchestrator REST API to manage workflows programmatically, export code, and generate workflows with AI.

What you'll be able to do after this module

  • Use the REST API to list, create, update, and delete workflows
  • Query execution status and step logs programmatically
  • Generate a full workflow from a natural language description using AI
  • Export a workflow as TypeScript code and a downloadable ZIP project

The Orchestrator REST API

All APIs are served from https://orchestrator.skytells.ai. Management APIs use session-based authentication (cookie). The webhook endpoint uses API key auth (covered in Module 4).

Workflow Management

MethodEndpointDescription
GET/api/workflowsList all your workflows
POST/api/workflows/createCreate a new workflow
GET/api/workflows/{id}Get a specific workflow
PATCH/api/workflows/{id}Update name, description, nodes, edges, visibility
DELETE/api/workflows/{id}Delete a workflow
POST/api/workflows/{id}/duplicateDuplicate with new IDs (integrations stripped)

Execution Monitoring

MethodEndpointDescription
GET/api/workflows/{id}/executionsList 50 most recent executions
GET/api/workflows/executions/{execId}/statusGet execution status + per-node status
GET/api/workflows/executions/{execId}/logsGet per-step logs (auto-redacted)
DELETE/api/workflows/{id}/executionsDelete all execution records

Integration Management

MethodEndpointDescription
GET/api/integrationsList integrations (config excluded)
POST/api/integrationsCreate integration (encrypted before storage)
GET/api/integrations/{id}Get with decrypted config (owner only)
PUT/api/integrations/{id}Update
DELETE/api/integrations/{id}Delete
POST/api/integrations/{id}/testTest credentials

API Keys

MethodEndpointDescription
GET/api/api-keysList keys (prefix only, never full key)
POST/api/api-keysCreate key (full key returned once)

Monitoring Executions

After triggering a workflow (via webhook or manually), you can poll for results:

loop [Poll until terminal status] POST /api/workflows/{id}/webhook { executionId, status: "running" } GET /executions/{execId}/status { status: "running" | "success" | "error" } GET /executions/{execId}/logs Per-step log entries Client Orchestrator

Execution Status Model

Workflow-level statuses:

StatusMeaning
pendingCreated, not yet started
runningActively executing steps
successAll steps completed successfully
errorOne or more steps failed
cancelledExecution was cancelled

Per-step statuses:

StatusMeaning
pendingStep not yet reached
runningStep currently executing
successStep completed
errorStep failed

Step Log Entry

Each step produces a log entry:

{
  "nodeId": "node1",
  "nodeName": "Generate Text",
  "nodeType": "action",
  "status": "success",
  "input": { "prompt": "..." },
  "output": { "text": "..." },
  "error": null,
  "startedAt": "2025-01-15T10:00:00Z",
  "completedAt": "2025-01-15T10:00:02Z",
  "duration": "2000"
}

AI Workflow Generation

Orchestrator can build entire workflows from a natural language description.

How to use it

Open AI Generate

Click the sparkles icon (AI Generate) in the toolbar.

Describe your workflow

Write a clear, specific description of what the workflow should do. Mention:

  • Which integrations to use (be specific: "use Perplexity" not "search the web")
  • What data flows between steps
  • Any branching logic
  • The trigger type

Example prompt:

When a webhook receives a customer support ticket, use AI Gateway to classify the priority as high or normal. If high, send a Slack message to #support-urgent. Otherwise, create a Linear ticket in the backlog.

Review the result

The AI streams operations to the canvas in real-time — you'll see nodes appear and connect.

The AI knows about:

  • All 45+ actions across all 15 plugins
  • All 3 system actions
  • Template variable syntax
  • Condition branching
  • Node positioning on the canvas

Finalize

After generation:

  1. Attach integrations — the AI creates the correct action types but can't assign credentials
  2. Review prompts and config — fine-tune values
  3. Test with Manual run before switching to production trigger

Tips for Better AI Generation

TipWhy
Name integrations explicitly"use Perplexity to search" > "search the web"
Mention branching conditionsThe AI needs explicit branching instructions
Specify trigger type"When a webhook receives..." > "When something happens..."
Describe data flow"take the text output and send it to Slack"

Code Export

Export any workflow as production-ready TypeScript code.

View Generated Code

Click ExportView Code in the toolbar. Orchestrator generates TypeScript using two special directives:

export async function myWorkflow() {
  "use workflow";  // marks the workflow entry point

  async function generateText() {
    "use step";    // marks each step for observability
    const response = await skytells.predictions.create({
      model: "truefusion-pro",
      input: { prompt: "..." },
    });
    return { success: true, data: response };
  }

  async function sendSlackMessage() {
    "use step";
    const textOutput = await generateText();
    await slack.chat.postMessage({
      channel: "#results",
      text: textOutput.data.text,
    });
  }

  await sendSlackMessage();
}

Key features:

  • "use workflow" — marks the function as a workflow entry point
  • "use step" — marks each step for logging and observability
  • Template variables are translated to JavaScript references
  • Dependencies are auto-calculated from the actions used

Download as ZIP

Click ExportDownload to get a complete Next.js project:

my-workflow/
├── workflows/
│   └── my-workflow.ts          # Generated workflow code
├── app/
│   ├── page.tsx                # Landing page
│   └── api/
│       └── workflows/
│           └── my-workflow/
│               └── route.ts    # API route to trigger
├── package.json                # Auto-calculated dependencies
└── tsconfig.json

Dependencies are auto-resolved based on the actions in your workflow:

Actions usedPackages included
AI Gateway Generate Textai, openai, @google/genai, zod
Slack Send Message@slack/web-api
Stripe operationsstripe
GitHub operations@octokit/rest
Resend Send Emailresend

To run the exported project:

unzip my-workflow.zip -d my-workflow
cd my-workflow
npm install
# Set environment variables for API keys
npm run dev
# API route available at http://localhost:3000/api/workflows/my-workflow

What you now understand

ConceptWhat it means
REST APIFull programmatic access to workflows, executions, integrations, and keys
Execution pollingCheck status and logs after triggering a workflow
Log redactionSensitive data automatically stripped from stored logs
AI generationNatural language → full workflow on canvas
Code exportTypeScript SDK code with "use workflow" / "use step" directives
ZIP downloadComplete Next.js project with auto-resolved dependencies

Up next: Production Best Practices — secure your workflows, debug failures, and operate at scale.

On this page