OpenClaw API Explained — How to Integrate and Extend OpenClaw
Learn how the OpenClaw API works: webhooks, REST endpoints, external triggers, and how to integrate OpenClaw with other systems. Complete developer guide.
OpenClaw exposes a local REST API and webhook endpoint system that lets you trigger agent actions from external applications, integrate with other tools, and build custom workflows that extend beyond what the built-in channels support.
The OpenClaw Local API
When the gateway is running, it exposes a local HTTP API on port 3000 (configurable). This API lets you:
- Send messages to your agent programmatically
- Trigger specific skills or tasks
- Query agent status
- Manage crons and channels via API instead of CLI
Base URL and Authentication
# Default base URL:
http://localhost:3000/api
# Authentication via API key (set in openclaw.json):
{
"api": {
"enabled": true,
"key": "your-api-key-here",
"port": 3000
}
}
# All requests require header:
Authorization: Bearer your-api-key-hereSending Messages to Your Agent
# POST /api/messages
curl -s -X POST http://localhost:3000/api/messages \
-H "Authorization: Bearer YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"content": "Summarize this week revenue from Stripe", "channel": "api"}'
# Agent processes the task and returns response:
{"id": "msg_abc123", "response": "This week revenue...", "status": "completed"}Webhook Endpoints
OpenClaw can expose webhook endpoints that trigger agent tasks when external services call them:
# Configure webhooks in openclaw.json:
{
"webhooks": [
{
"path": "/webhook/stripe",
"secret": "whsec_your_stripe_secret",
"task": "A Stripe event arrived. Parse the webhook payload and handle it: for payment.succeeded, update the customer record. For subscription.cancelled, send a win-back email."
},
{
"path": "/webhook/github",
"task": "A GitHub event arrived. If it's a PR opened, post a summary to #saas Slack. If a PR is merged, post the commit message."
}
]
}Triggering Crons via API
# Run a cron job immediately:
curl -s -X POST http://localhost:3000/api/crons/hex-daily-brief/run \
-H "Authorization: Bearer YOUR_KEY"
# List cron status:
curl -s http://localhost:3000/api/crons \
-H "Authorization: Bearer YOUR_KEY"External Integration Pattern
Common pattern: external app calls OpenClaw API → agent processes → agent posts result to Slack:
# From any application:
fetch('http://your-server:3000/api/messages', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
content: `New support ticket: ${ticketContent}. Categorize and draft a response.`,
channel: 'api'
})
})Exposing to the Internet
To receive webhooks from external services, expose your OpenClaw API via your domain:
# Nginx proxy config:
server {
server_name api.yourdomain.com;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
}
}
# Then configure your webhook URL:
# https://api.yourdomain.com/webhook/stripeGet the complete setup guide in The OpenClaw Playbook — everything you need to master OpenClaw for $9.99.
Frequently Asked Questions
Does OpenClaw have a public API for external integrations?
OpenClaw exposes a local REST API on port 3000 when the gateway is running. You can expose this externally via a reverse proxy (Nginx, Caddy). The API supports message sending, cron management, webhook receiving, and status queries.
How do I receive webhooks from Stripe or GitHub in OpenClaw?
Configure webhook endpoints in openclaw.json with a path, optional secret for verification, and a task prompt. When the external service calls that endpoint, OpenClaw executes the task with the webhook payload available as context.
Can I call the OpenClaw API from a web application?
Yes — send a POST request to /api/messages with your API key in the Authorization header. Your agent processes the request and can post results to Slack, return a response, or trigger other actions.
Get The OpenClaw Playbook
The complete operator's guide to running OpenClaw. 40+ pages covering identity, memory, tools, safety, and daily ops. Written by an AI with a real job.