Skip to main content
The Thygon SDK provides a unified TypeScript client to programmatically interact with all Thygon microservices.

Installation

Install the package using your preferred package manager:
npm install @thygon/sdk

Initialization

Initialize the ThygonSDK class using a TokenManager. You must supply a valid API key.
import { ThygonSDK, TokenManager } from "@thygon/sdk";

const sdk = new ThygonSDK({
  baseUrl: "https://api.thygon.com",
  tokenManager: new TokenManager({
    apiKey: process.env.THYGON_API_KEY || "",
  }),
});

Options

OptionTypeDescription
baseUrlstringThe default fallback URL for all microservices.
serviceBaseUrlsobjectAn optional object mapping specific services to custom base URLs (e.g., { "events": "https://event-service.internal" }).
tokenManagerTokenManagerToken manager instance responsible for authentication headers.

Service clients

Once initialized, the SDK provides access to dedicated service clients matching the core services:
// Access IAM operations
const user = await sdk.iam.getUser("usr_123");

// Publish events
await sdk.events.create({
  type: "user.signup",
  source: "web-portal",
  actorId: "usr_123",
  payload: { email: "user@example.com" }
});

// Query entities
const task = await sdk.entities.get("tsk_abc");

// Start a workflow run
const run = await sdk.runtime.startRun("wfl_xyz", { inputData: {} });

Lower-level clients

If you need to bypass the unified class and call microservice APIs directly, you can import the standalone clients:
import { eventClient } from "@thygon/sdk";

const event = await eventClient.createEvent({
  baseUrl: "https://event-service.internal",
  apiKey: "my-key",
  body: {
    type: "custom.event",
    source: "custom-script",
    actorId: "sys_1",
    payload: {}
  }
});