eavz

Python SDK

Official Python SDK for the Weavz API.

Python SDK

The official Python SDK provides a clean, Pythonic interface for the Weavz API.

Installation

bash
pip install weavz-sdk

Quick Start

python
from weavz_sdk import WeavzClient
 
client = WeavzClient(api_key="wvz_your_api_key")
 
# Execute an action
result = client.actions.execute(
    "slack",
    "send_channel_message",
    workspace_id="proj_abc123",
    input={"channel": "#general", "text": "Hello from Weavz!"},
    connection_external_id="my_slack",
)
 
print("Message sent:", result["output"])

Configuration

python
client = WeavzClient(
    api_key="wvz_your_api_key",
    base_url="https://api.weavz.io",  # Default
    timeout=30.0,                      # Request timeout in seconds
)
OptionRequiredDefaultDescription
api_keyYesYour API key (wvz_... prefix)
base_urlNohttps://api.weavz.ioAPI base URL
timeoutNo30.0Request timeout in seconds

Context Manager

The client supports Python's context manager protocol to automatically close the HTTP connection:

python
with WeavzClient(api_key="wvz_your_key") as client:
    result = client.actions.execute("slack", "send_channel_message", input={
        "channel": "#general",
        "text": "Hello!",
    })
# Connection automatically closed

You can also close manually:

python
client = WeavzClient(api_key="wvz_your_key")
try:
    # ... use client ...
    pass
finally:
    client.close()

Resources

The client exposes namespaced resources for each API area:

ResourceMethodsDescription
client.workspaceslist, create, get, delete, list_integrations, add_integration, update_integration, remove_integrationWorkspace management
client.connectionslist, create, delete, resolveConnection management
client.actionsexecuteExecute integration actions
client.triggerslist, enable, disable, testTrigger management
client.mcp_serverslist, create, get, update, delete, regenerate_token, add_tool, update_tool, delete_tool, execute_code, get_declarationsMCP server management
client.api_keyslist, create, deleteAPI key management
client.memberslist, create, update, deleteOrganization members
client.workspace_memberscreate, deleteWorkspace member management
client.integrationslist, get, resolve_options, resolve_property, oauth_statusIntegration metadata
client.connectcreate_token, get_sessionHosted connect flow
client.partialslist, get, create, update, delete, set_defaultInput partial presets

Common Operations

Managing Workspaces

python
# List workspaces
result = client.workspaces.list()
for ws in result["workspaces"]:
    print(ws["name"])
 
# Create a workspace
result = client.workspaces.create(name="My Workspace", slug="my-workspace")
workspace_id = result["workspace"]["id"]
 
# Delete a workspace
client.workspaces.delete(workspace_id)

Managing Connections

python
# Create an API key connection
result = client.connections.create(
    type="SECRET_TEXT",
    integration_name="openai",
    external_id="tenant_123_openai",
    display_name="OpenAI Key",
    secret_text="sk-...",
)
 
# Resolve a connection
resolved = client.connections.resolve(
    integration_name="openai",
    workspace_id="proj_abc123",
    external_id="tenant_123_openai",
)
 
# Delete a connection
client.connections.delete(result["connection"]["id"])

Executing Actions

python
result = client.actions.execute(
    "github",
    "create_issue",
    workspace_id="proj_abc123",
    input={
        "repo": "my-org/my-repo",
        "title": "Bug Report",
        "body": "Something went wrong",
        "labels": ["bug"],
    },
    connection_external_id="my_github",
)
 
print("Issue created:", result["output"])

Managing MCP Servers

python
# Create a server
result = client.mcp_servers.create(
    name="AI Agent Tools",
    mode="TOOLS",
    workspace_id="proj_abc123",
)
server_id = result["server"]["id"]
token = result["bearerToken"]
endpoint = result["mcpEndpoint"]
 
# Create a server scoped to an end user
result = client.mcp_servers.create(
    name="User Agent",
    workspace_id="proj_abc123",
    end_user_id="user_123",
)
user_token = result["bearerToken"]
 
# Add a tool
client.mcp_servers.add_tool(
    server_id,
    integration_name="slack",
    action_name="send_channel_message",
    connection_id="conn_abc",
)
 
# Regenerate token
result = client.mcp_servers.regenerate_token(server_id)
new_token = result["bearerToken"]

Managing Triggers

python
# Enable a trigger
result = client.triggers.enable(
    integration_name="github",
    trigger_name="new_push",
    workspace_id="proj_abc123",
    callback_url="https://yourapp.com/webhooks/github",
    connection_external_id="my_github",
)
trigger_id = result["triggerSource"]["id"]
 
# List active triggers
result = client.triggers.list()
for trigger in result["triggers"]:
    print(f"{trigger['integrationName']}.{trigger['triggerName']}")
 
# Disable a trigger
client.triggers.disable(trigger_id)

Managing Input Partials

python
# Create a partial (saved parameter preset)
result = client.partials.create(
    name="Default Slack Channel",
    workspace_id="proj_abc123",
    integration_name="slack",
    action_name="send_channel_message",
    values={"channel": "#general"},
    enforced_keys=["channel"],
)
partial = result["partial"]
 
# List partials for a workspace
result = client.partials.list(workspace_id="proj_abc123")
 
# Set as default for this action
client.partials.set_default(partial["id"], is_default=True)
 
# Use partial with action execution
result = client.actions.execute(
    "slack",
    "send_channel_message",
    workspace_id="proj_abc123",
    partial_ids=[partial["id"]],
    input={"text": "Hello!"},  # channel comes from the partial
)
 
# Delete a partial
client.partials.delete(partial["id"])

Hosted Connect Flow

Use the hosted connect page to create OAuth2 connections. Create a token, open the connect page, and poll for the result:

python
# Step 1: Create a connect token
result = client.connect.create_token(
    integration_name="google-sheets",
    connection_name="Google Sheets",
    external_id="tenant_123_gsheets",
    workspace_id="proj_abc123",
)
token = result["token"]
connect_url = result["connectUrl"]
# result also contains: expiresAt
 
# Step 2: Open connect_url in a browser popup to complete authorization

Error Handling

All API errors raise WeavzError with structured error information:

python
from weavz_sdk import WeavzClient, WeavzError
 
client = WeavzClient(api_key="wvz_your_key")
 
try:
    client.actions.execute(
        "slack", "send_channel_message",
        workspace_id="proj_abc123",
        input={"channel": "invalid", "text": "Hello!"},
    )
except WeavzError as e:
    print(f"Message: {e}")         # Human-readable error message
    print(f"Code: {e.code}")       # Machine-readable code (e.g., "ACTION_FAILED")
    print(f"Status: {e.status}")   # HTTP status code (e.g., 400)
    print(f"Details: {e.details}") # Additional 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

Type Hints

The Python SDK includes type hints and Pydantic models for all API responses. You get IDE autocomplete and validation for all resource methods.

Key Types

python
from weavz_sdk import WeavzClient, WeavzError
from weavz_sdk.types import (
    InputPartial,
    WorkspaceIntegration,
    McpServer,
    McpServerTool,
    Connection,
    Workspace,
    TriggerSource,
)
TypeDescription
WeavzClientMain client class with all resource methods
WeavzErrorException class with message, code, status, details
InputPartialPartial preset with values, enforced_keys, is_default
WorkspaceIntegrationIntegration instance on a workspace with alias and connection strategy
McpServerMCP server with mode, mcp_endpoint
McpServerToolTool on an MCP server with integration_alias, partial_ids
ConnectionConnection with type, integration_name, external_id
WorkspaceWorkspace with name, slug
TriggerSourceActive trigger with integration_name, trigger_name, callback_url

Integration Input Types

The SDK ships with generated Pydantic models for all 500+ integration action inputs:

python
from weavz_sdk.integrations import (
    # Slack
    SlackSendChannelMessageInput,
    SlackSendDirectMessageInput,
    # GitHub
    GithubCreateIssueInput,
    GithubCreatePullRequestInput,
    # Google Sheets
    GoogleSheetsInsertRowInput,
    GoogleSheetsReadRowsInput,
    # ... all integrations follow the same pattern
)
 
# Validated input with autocomplete
input_data = SlackSendChannelMessageInput(
    channel="#general",
    text="Typed input!",
)
 
client.actions.execute(
    "slack",
    "send_channel_message",
    workspace_id="proj_abc123",
    input=input_data.model_dump(),
)

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

Python Version

The SDK requires Python 3.10 or later and depends on: