@timbrix/sdk
TypeScript/JavaScript client for the Timbrix API.
Installation
npm install @timbrix/sdk
pnpm add @timbrix/sdk
yarn add @timbrix/sdk
Usage
With API Key (Machine-to-Machine)
import { TimbrixClient } from "@timbrix/sdk"
const client = new TimbrixClient({
apiKey: "sk_live_abc123...",
baseUrl: "https://api.timbrix.com",
})
const webhooks = await client.webhooks.list("organization-id")
const webhook = await client.webhooks.create("organization-id", {
url: "https://example.com/webhooks",
events: ["organization.created", "member.added"],
})
With Bearer Token (User Authentication)
import { TimbrixClient } from "@timbrix/sdk"
const client = new TimbrixClient({
bearerToken: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
baseUrl: "https://api.timbrix.com",
})
const orgs = await client.organizations.list()
const org = await client.organizations.create({
name: "Acme Corp",
slug: "acme-corp",
})
API Reference
Organizations
await client.organizations.list()
await client.organizations.get("acme-corp")
await client.organizations.create({
name: "Acme Corp",
slug: "acme-corp",
})
await client.organizations.update("acme-corp", {
name: "New Name",
logo: "https://example.com/logo.png",
})
await client.organizations.delete("acme-corp")
Webhooks
await client.webhooks.list("organization-id")
await client.webhooks.get("organization-id", "webhook-id")
await client.webhooks.create("organization-id", {
url: "https://example.com/webhooks",
events: ["organization.created"],
})
await client.webhooks.update("organization-id", "webhook-id", {
url: "https://new-url.com/webhooks",
isActive: false,
})
await client.webhooks.delete("organization-id", "webhook-id")
await client.webhooks.deliveries("organization-id", "webhook-id")
await client.webhooks.test("organization-id", "webhook-id")
API Keys
await client.apiKeys.list("organization-id")
await client.apiKeys.get("organization-id", "api-key-id")
await client.apiKeys.create("organization-id", {
name: "Production Key",
expiresAt: "2025-12-31T23:59:59Z",
})
await client.apiKeys.update("organization-id", "api-key-id", {
name: "New Name",
})
await client.apiKeys.delete("organization-id", "api-key-id")
await client.apiKeys.stats("organization-id", "api-key-id")
await client.apiKeys.validate("organization-id", "sk_live_abc123...")
Error Handling
import { TimbrixClient, type TimbrixError } from "@timbrix/sdk"
const client = new TimbrixClient({ apiKey: "sk_live_abc123..." })
try {
await client.organizations.get("non-existent")
} catch (error) {
const timbrixError = error as TimbrixError
console.error(`Error ${timbrixError.statusCode}: ${timbrixError.message}`)
}
TypeScript Support
The client is written in TypeScript and includes full type definitions:
import type {
Organization,
Webhook,
ApiKey,
CreateWebhookInput,
WebhookEvent,
} from "@timbrix/sdk"
License
MIT