eavz

TypeScript SDK

Official TypeScript SDK for the Weavz API.

TypeScript SDK

The official TypeScript SDK provides a typed, ergonomic interface for the Weavz API.

Installation

bash
npm install @weavz/sdk

Quick Start

typescript
import { WeavzClient } from '@weavz/sdk'
 
const client = new WeavzClient({
  apiKey: 'wvz_your_api_key',
})
 
// Execute an action
const { output } = await client.actions.execute('slack', 'send_channel_message', {
  workspaceId: 'proj_abc123',
  input: { channel: '#general', text: 'Hello from Weavz!' },
  connectionExternalId: 'my_slack',
})
 
console.log('Message sent:', output)

Configuration

typescript
const client = new WeavzClient({
  apiKey: 'wvz_your_api_key',
  baseUrl: 'https://api.weavz.io',  // Default
})
OptionRequiredDefaultDescription
apiKeyYesYour API key (wvz_... prefix)
baseUrlNohttps://api.weavz.ioAPI base URL

Resources

The client exposes namespaced resources for each API area:

ResourceMethodsDescription
client.workspaceslist, create, get, delete, listIntegrations, addIntegration, updateIntegration, removeIntegrationWorkspace management
client.connectionslist, create, delete, resolveConnection management
client.actionsexecuteExecute integration actions
client.triggerslist, enable, disable, testTrigger management
client.mcpServerslist, create, get, update, delete, regenerateToken, addTool, updateTool, deleteTool, executeCode, getDeclarationsMCP server management
client.apiKeyslist, create, deleteAPI key management
client.memberslist, create, update, deleteOrganization members
client.workspaceMemberscreate, deleteWorkspace member management
client.integrationslist, get, resolveOptions, resolveProperty, oauthStatusIntegration metadata
client.connectcreateToken, getSession, popupHosted connect flow
client.partialslist, get, create, update, delete, setDefaultInput partial presets

Common Operations

Managing Workspaces

typescript
// List workspaces
const { workspaces } = await client.workspaces.list()
 
// Create a workspace
const { workspace } = await client.workspaces.create({
  name: 'My Workspace',
  slug: 'my-workspace',
})
 
// Delete a workspace
await client.workspaces.delete(workspace.id)

Managing Connections

typescript
// Create an API key connection
const { connection } = await client.connections.create({
  type: 'SECRET_TEXT',
  integrationName: 'openai',
  externalId: 'tenant_123_openai',
  displayName: 'OpenAI Key',
  secretText: 'sk-...',
})
 
// Resolve a connection
const resolved = await client.connections.resolve({
  integrationName: 'openai',
  workspaceId: 'proj_abc123',
  externalId: 'tenant_123_openai',
})
 
// Delete a connection
await client.connections.delete(connection.id)

Executing Actions

typescript
const { output } = await client.actions.execute('github', 'create_issue', {
  workspaceId: 'proj_abc123',
  input: {
    repo: 'my-org/my-repo',
    title: 'Bug Report',
    body: 'Something went wrong',
    labels: ['bug'],
  },
  connectionExternalId: 'my_github',
})

Managing MCP Servers

typescript
// Create a server
const { server, bearerToken, mcpEndpoint } = await client.mcpServers.create({
  name: 'AI Agent Tools',
  mode: 'TOOLS',
  workspaceId: 'proj_abc123',
})
 
// Create a server scoped to an end user
const { server: userServer, bearerToken: userToken } = await client.mcpServers.create({
  name: 'User Agent',
  workspaceId: 'proj_abc123',
  endUserId: 'user_123',
})
 
// Add a tool
await client.mcpServers.addTool(server.id, {
  integrationName: 'slack',
  actionName: 'send_channel_message',
  connectionId: 'conn_abc',
})
 
// Regenerate token
const { bearerToken: newToken } = await client.mcpServers.regenerateToken(server.id)

Managing Triggers

typescript
// Enable a trigger
const { triggerSource } = await client.triggers.enable({
  integrationName: 'github',
  triggerName: 'new_push',
  workspaceId: 'proj_abc123',
  callbackUrl: 'https://yourapp.com/webhooks/github',
  connectionExternalId: 'my_github',
})
 
// List active triggers
const { triggers } = await client.triggers.list()
 
// Disable a trigger
await client.triggers.disable(triggerSource.id)

Managing Input Partials

typescript
// Create a partial (saved parameter preset)
const { partial } = await client.partials.create({
  name: 'Default Slack Channel',
  workspaceId: 'proj_abc123',
  integrationName: 'slack',
  actionName: 'send_channel_message',
  values: { channel: '#general' },
  enforcedKeys: ['channel'],
})
 
// List partials for a workspace
const { partials } = await client.partials.list({ workspaceId: 'proj_abc123' })
 
// Set as default for this action
await client.partials.setDefault(partial.id, true)
 
// Use partial with action execution
const { output } = await client.actions.execute('slack', 'send_channel_message', {
  workspaceId: 'proj_abc123',
  partialIds: [partial.id],
  input: { text: 'Hello!' }, // channel comes from the partial
})
 
// Delete a partial
await client.partials.delete(partial.id)

Hosted Connect Flow

Use the hosted connect page to create OAuth2 connections. The flow is two steps: create a token, then open the popup:

typescript
// Step 1: Create a connect session
const session = await client.connect.createToken({
  integrationName: 'google-sheets',
  connectionName: 'Google Sheets',
  externalId: 'tenant_123_gsheets',
  workspaceId: 'proj_abc123',
})
 
// Step 2: Open the popup (browser environments)
const result = await client.connect.popup({
  token: session.token,
  connectUrl: session.connectUrl,
})
 
console.log('Connection created:', result.connection.id)

For server-side or custom flows, create a token and open the connect URL manually:

typescript
// Step 1: Create a connect token
const { token, connectUrl } = await client.connect.createToken({
  integrationName: 'google-sheets',
  connectionName: 'Google Sheets',
  externalId: 'tenant_123_gsheets',
  workspaceId: 'proj_abc123',
})
 
// Step 2: Open connectUrl in a browser window...
// The response contains: token, connectUrl, expiresAt

Error Handling

All API errors throw WeavzError with structured error information:

typescript
import { WeavzClient, WeavzError } from '@weavz/sdk'
 
const client = new WeavzClient({ apiKey: 'wvz_your_key' })
 
try {
  await client.actions.execute('slack', 'send_channel_message', {
    workspaceId: 'proj_abc123',
    input: { channel: 'invalid', text: 'Hello!' },
  })
} catch (err) {
  if (err instanceof WeavzError) {
    console.error(err.message)   // Human-readable error message
    console.error(err.code)      // Machine-readable error code (e.g., "ACTION_FAILED")
    console.error(err.status)    // HTTP status code (e.g., 400)
    console.error(err.details)   // Additional error details (if available)
  }
}

Common Error Codes

CodeDescription
VALIDATION_ERRORInvalid request parameters
ACTION_FAILEDAction execution failed
CONNECTION_REQUIREDAction needs a connection
CONNECTION_NOT_FOUNDConnection doesn't exist
INTEGRATION_NOT_FOUNDInvalid integration name
QUOTA_EXCEEDEDMonthly usage limit reached
RATE_LIMITEDToo many requests

TypeScript Support

The SDK is written in TypeScript and ships with full type definitions. You get autocomplete and type checking for all resource methods and their parameters.

typescript
// Typed integration inputs (generated from integration schemas)
import type { SlackSendChannelMessageInput } from '@weavz/sdk'
 
const input: SlackSendChannelMessageInput = {
  channel: '#general',
  text: 'Typed input!',
}
 
await client.actions.execute('slack', 'send_channel_message', {
  workspaceId: 'proj_abc123',
  input,
})

Key Types

typescript
import type {
  WeavzClient,
  WeavzError,
  InputPartial,
  WorkspaceIntegration,
  McpServer,
  McpServerTool,
  Connection,
  Workspace,
  TriggerSource,
} from '@weavz/sdk'
TypeDescription
WeavzClientMain client class with all resource methods
WeavzErrorError class with message, code, status, details
InputPartialPartial preset with values, enforcedKeys, isDefault
WorkspaceIntegrationIntegration instance on a workspace with alias and connection strategy
McpServerMCP server with mode, mcpEndpoint
McpServerToolTool on an MCP server with integrationAlias, partialIds
ConnectionConnection with type, integrationName, externalId
WorkspaceWorkspace with name, slug
TriggerSourceActive trigger with integrationName, triggerName, callbackUrl

Integration Input Types

The SDK ships with generated input types for all 500+ integrations. Import them by pattern:

typescript
import type {
  // Slack
  SlackSendChannelMessageInput,
  SlackSendDirectMessageInput,
  // GitHub
  GithubCreateIssueInput,
  GithubCreatePullRequestInput,
  // Google Sheets
  GoogleSheetsInsertRowInput,
  GoogleSheetsReadRowsInput,
  // ... all integrations follow the same pattern
} from '@weavz/sdk'

The naming pattern is {IntegrationName}{ActionName}Input in PascalCase.