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
npm install @weavz/sdkQuick Start
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
const client = new WeavzClient({
apiKey: 'wvz_your_api_key',
baseUrl: 'https://api.weavz.io', // Default
})| Option | Required | Default | Description |
|---|---|---|---|
apiKey | Yes | — | Your API key (wvz_... prefix) |
baseUrl | No | https://api.weavz.io | API base URL |
Resources
The client exposes namespaced resources for each API area:
| Resource | Methods | Description |
|---|---|---|
client.workspaces | list, create, get, delete, listIntegrations, addIntegration, updateIntegration, removeIntegration | Workspace management |
client.connections | list, create, delete, resolve | Connection management |
client.actions | execute | Execute integration actions |
client.triggers | list, enable, disable, test | Trigger management |
client.mcpServers | list, create, get, update, delete, regenerateToken, addTool, updateTool, deleteTool, executeCode, getDeclarations | MCP server management |
client.apiKeys | list, create, delete | API key management |
client.members | list, create, update, delete | Organization members |
client.workspaceMembers | create, delete | Workspace member management |
client.integrations | list, get, resolveOptions, resolveProperty, oauthStatus | Integration metadata |
client.connect | createToken, getSession, popup | Hosted connect flow |
client.partials | list, get, create, update, delete, setDefault | Input partial presets |
Common Operations
Managing Workspaces
// 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
// 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
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
// 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
// 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
// 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:
// 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:
// 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, expiresAtError Handling
All API errors throw WeavzError with structured error information:
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
| Code | Description |
|---|---|
VALIDATION_ERROR | Invalid request parameters |
ACTION_FAILED | Action execution failed |
CONNECTION_REQUIRED | Action needs a connection |
CONNECTION_NOT_FOUND | Connection doesn't exist |
INTEGRATION_NOT_FOUND | Invalid integration name |
QUOTA_EXCEEDED | Monthly usage limit reached |
RATE_LIMITED | Too 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.
// 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
import type {
WeavzClient,
WeavzError,
InputPartial,
WorkspaceIntegration,
McpServer,
McpServerTool,
Connection,
Workspace,
TriggerSource,
} from '@weavz/sdk'| Type | Description |
|---|---|
WeavzClient | Main client class with all resource methods |
WeavzError | Error class with message, code, status, details |
InputPartial | Partial preset with values, enforcedKeys, isDefault |
WorkspaceIntegration | Integration instance on a workspace with alias and connection strategy |
McpServer | MCP server with mode, mcpEndpoint |
McpServerTool | Tool on an MCP server with integrationAlias, partialIds |
Connection | Connection with type, integrationName, externalId |
Workspace | Workspace with name, slug |
TriggerSource | Active trigger with integrationName, triggerName, callbackUrl |
Integration Input Types
The SDK ships with generated input types for all 500+ integrations. Import them by pattern:
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.