Skip to main content
This guide helps you set up the Thygon SDK and emit your first event.

Prerequisites

Before you begin, you must have:
  • Node.js 18 or higher installed on your local machine.
  • A Thygon API key. You can generate one in the API Keys tab of the Thygon console.

Install the SDK

Add the Thygon SDK package to your project dependencies.
npm install @thygon/sdk

Configure the client

Initialize the ThygonSDK client using your API key. We recommend storing the key in the THYGON_API_KEY environment variable.
import { ThygonSDK, TokenManager } from "@thygon/sdk";

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

Emit your first event

Create and publish an event to your organization’s ledger. This notifies all subscribed workflows and agents.
async function main() {
  const event = await sdk.events.create({
    type: "support.ticket.created",
    source: "quickstart-script",
    actorId: "system-account-id",
    payload: {
      ticketId: "TCK-101",
      title: "Cannot access billing portal",
      priority: "high",
    },
  });

  console.log(`Published event: ${event.id}`);
}

main().catch(console.error);

Next steps

Now that you have emitted your first event, you can design automation rules and workflows: