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
pip install weavz-sdkQuick Start
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
client = WeavzClient(
api_key="wvz_your_api_key",
base_url="https://api.weavz.io", # Default
timeout=30.0, # Request timeout in seconds
)| Option | Required | Default | Description |
|---|---|---|---|
api_key | Yes | — | Your API key (wvz_... prefix) |
base_url | No | https://api.weavz.io | API base URL |
timeout | No | 30.0 | Request timeout in seconds |
Context Manager
The client supports Python's context manager protocol to automatically close the HTTP connection:
with WeavzClient(api_key="wvz_your_key") as client:
result = client.actions.execute("slack", "send_channel_message", input={
"channel": "#general",
"text": "Hello!",
})
# Connection automatically closedYou can also close manually:
client = WeavzClient(api_key="wvz_your_key")
try:
# ... use client ...
pass
finally:
client.close()Resources
The client exposes namespaced resources for each API area:
| Resource | Methods | Description |
|---|---|---|
client.workspaces | list, create, get, delete, list_integrations, add_integration, update_integration, remove_integration | 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.mcp_servers | list, create, get, update, delete, regenerate_token, add_tool, update_tool, delete_tool, execute_code, get_declarations | MCP server management |
client.api_keys | list, create, delete | API key management |
client.members | list, create, update, delete | Organization members |
client.workspace_members | create, delete | Workspace member management |
client.integrations | list, get, resolve_options, resolve_property, oauth_status | Integration metadata |
client.connect | create_token, get_session | Hosted connect flow |
client.partials | list, get, create, update, delete, set_default | Input partial presets |
Common Operations
Managing Workspaces
# 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
# 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
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
# 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
# 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
# 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:
# 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 authorizationError Handling
All API errors raise WeavzError with structured error information:
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
| 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 |
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
from weavz_sdk import WeavzClient, WeavzError
from weavz_sdk.types import (
InputPartial,
WorkspaceIntegration,
McpServer,
McpServerTool,
Connection,
Workspace,
TriggerSource,
)| Type | Description |
|---|---|
WeavzClient | Main client class with all resource methods |
WeavzError | Exception class with message, code, status, details |
InputPartial | Partial preset with values, enforced_keys, is_default |
WorkspaceIntegration | Integration instance on a workspace with alias and connection strategy |
McpServer | MCP server with mode, mcp_endpoint |
McpServerTool | Tool on an MCP server with integration_alias, partial_ids |
Connection | Connection with type, integration_name, external_id |
Workspace | Workspace with name, slug |
TriggerSource | Active trigger with integration_name, trigger_name, callback_url |
Integration Input Types
The SDK ships with generated Pydantic models for all 500+ integration action inputs:
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: