Saltar al contenido principal
Reference

SDKs

Official client libraries for the WorkFlows API. Both SDKs provide typed interfaces for all API resources with built-in error handling and rate limit management.

JS

JavaScript / TypeScript SDK

Installation

Terminal
npm install @workflows/sdk
# or
yarn add @workflows/sdk
# or
pnpm add @workflows/sdk

Quick Start

TypeScript
import { WorkflowsClient } from "@workflows/sdk";

const client = new WorkflowsClient({
  apiKey: "wf_live_your_key",
});

// List projects
const { data: projects } = await client.projects.list();
console.log(projects);

// Ask a question with AI
const response = await client.chat.ask({
  message: "What were the top 5 suppliers by delivery delay in Q1?",
  projectId: "proj_xxx",
});
console.log(response.answer);

// Create an alert
const alert = await client.alerts.create({
  title: "Low inventory: Raw Material A",
  severity: "critical",
  projectId: "proj_xxx",
  description: "Stock below minimum threshold",
});

Error Handling

TypeScript
import {
  WorkflowsClient,
  AuthenticationError,
  RateLimitError,
  PlanRequiredError,
  ValidationError,
  NotFoundError,
} from "@workflows/sdk";

const client = new WorkflowsClient({ apiKey: "wf_live_your_key" });

try {
  await client.projects.list();
} catch (error) {
  if (error instanceof AuthenticationError) {
    console.error("Invalid or expired API key");
  } else if (error instanceof RateLimitError) {
    console.error("Rate limited — retry later");
  } else if (error instanceof PlanRequiredError) {
    console.error("Upgrade to Business plan for API access");
  } else if (error instanceof ValidationError) {
    console.error("Invalid request data:", error.message);
  } else if (error instanceof NotFoundError) {
    console.error("Resource not found");
  }
}

Configuration

TypeScript
const client = new WorkflowsClient({
  apiKey: "wf_live_your_key",
  // Custom base URL (for self-hosted instances)
  baseUrl: "https://custom.example.com/api/v1",
});
PY

Python SDK

Installation

Terminal
pip install workflows-sdk
# or
poetry add workflows-sdk

Quick Start (Sync)

Python
from workflows_sdk import WorkflowsClient

client = WorkflowsClient(api_key="wf_live_your_key")

# List projects
projects = client.projects.list()
print(projects["data"])

# Ask a question with AI
response = client.chat.ask(
    message="What were the top 5 suppliers by delivery delay in Q1?",
    project_id="proj_xxx",
)
print(response["answer"])

# Create an alert
alert = client.alerts.create(
    title="Low inventory: Raw Material A",
    severity="critical",
    project_id="proj_xxx",
    description="Stock below minimum threshold",
)

# Context manager (auto-close)
with WorkflowsClient(api_key="wf_live_...") as client:
    projects = client.projects.list()
    print(projects["data"])

Async Client

Python
from workflows_sdk import AsyncWorkflowsClient

async def main():
    async with AsyncWorkflowsClient(api_key="wf_live_...") as client:
        projects = await client.projects.list()
        alerts = await client.alerts.list()
        print(projects["data"], alerts["data"])

Error Handling

Python
from workflows_sdk import WorkflowsClient
from workflows_sdk.errors import (
    AuthenticationError,
    RateLimitError,
    PlanRequiredError,
    ValidationError,
    NotFoundError,
)

client = WorkflowsClient(api_key="wf_live_your_key")

try:
    client.projects.list()
except AuthenticationError:
    print("Invalid or expired API key")
except RateLimitError:
    print("Rate limited — retry later")
except PlanRequiredError:
    print("Upgrade to Business plan for API access")

Available Resources

Both SDKs expose the same resource namespaces:

client.alerts
client.chat
client.connections
client.exports
client.history
client.projects
client.usage
client.users
client.webhooks

Embed SDK

The Embed SDK lets you embed WorkFlows dashboards directly into your own application using a lightweight web component or iframe.

HTML
<script src="https://www.workflows.com.es/embed/sdk.js"></script>

<workflows-embed
  token="embed_token_xxx"
  dashboard="dashboard_id"
  theme="dark"
></workflows-embed>
Generate embed tokens from Dashboard → Developers → Embed Tokens or via POST /api/v1/embed/tokens.