Skip to main content
The Plugin SDK provides APIs for registering channels, tools, hooks, services, and HTTP handlers. Import from openclaw/plugin-sdk:

Plugin API

The OpenClawPluginApi is passed to your plugin’s register and activate functions.

Properties

string
Plugin identifier (e.g., "matrix", "my-plugin")
string
Plugin display name
string
Plugin version from package.json
string
Plugin description
string
Absolute path to the plugin entry point
OpenClawConfig
OpenClaw configuration object. Access via api.config.channels, api.config.agents, etc.
Record<string, unknown>
Plugin-specific configuration from config.json under plugins.entries[id].config
PluginRuntime
Runtime services for media, messaging, logging, and more. See Runtime Services.
PluginLogger
Scoped logger for plugin messages:

Registration Methods

(tool: AnyAgentTool | OpenClawPluginToolFactory, opts?: OpenClawPluginToolOptions) => void
Register an agent tool. Tools are exposed to the LLM and can be called during agent runs.
Options:
  • name?: string - Tool name override
  • names?: string[] - Multiple tool names (for tool factories)
  • optional?: boolean - Require explicit allowlisting in agent config
(events: string | string[], handler: InternalHookHandler, opts?: OpenClawPluginHookOptions) => void
Register a lifecycle hook. Hooks intercept events at key points in the message lifecycle.
See Hooks for available events.
(registration: OpenClawPluginChannelRegistration | ChannelPlugin) => void
Register a channel plugin. Channel plugins integrate messaging platforms.
See Channels for details.
(service: OpenClawPluginService) => void
Register a background service. Services run persistent background tasks.
(params: { path: string; handler: OpenClawPluginHttpRouteHandler }) => void
Register an HTTP route for webhooks or custom endpoints.
Routes are automatically normalized to prevent conflicts.
(handler: OpenClawPluginHttpHandler) => void
Register a global HTTP handler. Handlers are called for all requests.
(registrar: OpenClawPluginCliRegistrar, opts?: { commands?: string[] }) => void
Register CLI commands. Add custom commands to the openclaw CLI.
(command: OpenClawPluginCommandDefinition) => void
Register a plugin command. Plugin commands bypass the LLM agent and are processed before built-in commands.
(provider: ProviderPlugin) => void
Register an authentication provider. Providers integrate with openclaw login.
(method: string, handler: GatewayRequestHandler) => void
Register a custom gateway method. Gateway methods are JSON-RPC endpoints exposed via the gateway.

Utility Methods

(input: string) => string
Resolve paths relative to the plugin source directory.
<K extends PluginHookName>(hookName: K, handler: PluginHookHandlerMap[K], opts?: { priority?: number }) => void
Alternative API for registering lifecycle hooks with typed event handlers.

Runtime Services

The api.runtime object provides access to OpenClaw’s core services.

Config

Media

Text Processing

Reply Dispatching

Logging

State Directory

Channel-Specific Services

The runtime provides channel-specific helpers:
See the runtime types for the complete API.

Plugin SDK Exports

The openclaw/plugin-sdk package exports types and utilities:

Types

Helper Functions

Channel Helpers

Config Schemas (Zod)

Example: Complete Plugin

Next Steps

  • Hooks - Implement lifecycle hooks
  • Tools - Build custom agent tools
  • Channels - Create channel integrations
  • Examples - Real-world plugin examples