REST Endpoints
The OpenClaw Gateway provides HTTP REST endpoints for specific use cases including OpenAI compatibility, webhooks, and tool invocation.
OpenAI-Compatible Chat Completions
POST /v1/chat/completions
OpenAI-compatible chat completions endpoint.
Authentication:
Authorization: Bearer your-token-here
Request Body:
Model identifier (e.g., "openclaw", "gpt-4"). Maps to OpenClaw agent.
Array of message objects with role and content
Enable streaming responses (SSE)
User identifier for session scoping
Response:
Completion ID (format: chatcmpl_<uuid>)
"chat.completion" or "chat.completion.chunk" (for streaming)
Model identifier from request
Array of completion choices
Example (Non-Streaming):
curl -X POST http://localhost:18789/v1/chat/completions \
-H "Authorization: Bearer your-token" \
-H "Content-Type: application/json" \
-d '{
"model": "openclaw",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is OpenClaw?"}
]
}'
Response:
{
"id": "chatcmpl_123e4567-e89b-12d3-a456-426614174000",
"object": "chat.completion",
"created": 1234567890,
"model": "openclaw",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "OpenClaw is an open-source AI agent framework..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}
Example (Streaming):
curl -X POST http://localhost:18789/v1/chat/completions \
-H "Authorization: Bearer your-token" \
-H "Content-Type: application/json" \
-d '{
"model": "openclaw",
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}'
Streaming Response (SSE):
data: {"id":"chatcmpl_123","object":"chat.completion.chunk","created":1234567890,"model":"openclaw","choices":[{"index":0,"delta":{"role":"assistant"}}]}
data: {"id":"chatcmpl_123","object":"chat.completion.chunk","created":1234567890,"model":"openclaw","choices":[{"index":0,"delta":{"content":"Hello"}}]}
data: [DONE]
Webhook Endpoints (Hooks)
POST /hooks/:path
Custom webhook endpoints for external integrations.
Configuration:
hooks:
enabled: true
token: "your-hook-token"
path: "/hooks"
maxBodyBytes: 262144
Authentication:
Authorization: Bearer your-hook-token
Or:
X-OpenClaw-Token: your-hook-token
Wake Endpoint:
POST /hooks/wake
Content-Type: application/json
{
"text": "Wake up message",
"mode": "now" // or "next-heartbeat"
}
Agent Endpoint:
POST /hooks/agent
Content-Type: application/json
{
"message": "User message",
"agentId": "default",
"sessionKey": "hook:session-123",
"name": "Webhook User",
"deliver": true,
"channel": "signal",
"to": "+1234567890",
"model": "gpt-4",
"thinking": "high",
"wakeMode": "now",
"timeoutSeconds": 300
}
User message to send to agent
Target agent ID (defaults to configured default)
Session key for conversation context
Display name for the sender
Whether to deliver response via channel
Channel to deliver response (e.g., "signal", "telegram", "discord")
Recipient identifier (phone number, user ID, etc.)
Override model for this request
Thinking budget: "low", "medium", "high"
"now" or "next-heartbeat"
Request timeout in seconds
Response:
{
"ok": true,
"runId": "unique-run-id"
}
Custom Mappings:
You can define custom webhook mappings:
hooks:
mappings:
- path: "github"
action:
kind: "agent"
message: "{{ payload.commits[0].message }}"
channel: "discord"
to: "#dev-notifications"
See Hooks for details.
POST /api/tools/invoke
HTTP-based tool invocation endpoint.
Authentication:
Authorization: Bearer your-token
Request Body:
Example:
curl -X POST http://localhost:18789/api/tools/invoke \
-H "Authorization: Bearer your-token" \
-H "Content-Type: application/json" \
-d '{
"tool": "weather",
"params": {
"location": "San Francisco"
}
}'
Response:
{
"ok": true,
"result": {
"temperature": 68,
"conditions": "Partly cloudy"
}
}
Channel Endpoints
POST /api/slack/events
Slack Events API endpoint for receiving Slack app events.
Authentication: Handled via Slack signing secret verification.
Request Body: Slack event payload (see Slack Events API).
Response:
See Slack Integration for setup.
/api/channels/:channelId/*
Channel-specific HTTP endpoints exposed by channel plugins.
Authentication:
Authorization: Bearer your-token
Examples:
/api/channels/telegram/webhook - Telegram webhook
/api/channels/discord/interactions - Discord interactions
Channel endpoints are dynamically registered by plugins. See individual channel documentation.
Health Check
GET /health
Health check endpoint (no authentication required).
Response:
{
"ok": true,
"status": "healthy"
}
Error Responses
All REST endpoints return standard error responses:
400 Bad Request:
{
"error": {
"message": "Invalid request body",
"type": "invalid_request_error"
}
}
401 Unauthorized:
{
"error": {
"message": "Unauthorized",
"type": "authentication_error"
}
}
429 Too Many Requests:
{
"error": {
"message": "Too many failed authentication attempts. Please try again later.",
"type": "rate_limited"
}
}
500 Internal Server Error:
{
"error": {
"message": "Internal error",
"type": "api_error"
}
}
Next Steps
Hooks
Configure webhook integrations
OpenAI Compatibility
Use OpenAI-compatible API