OpenClaw API & Automation Recipes: CLI, HTTP, and Webhooks
Reference: API reference and Prism API overview.
CLI health check (cron-friendly)
#!/bin/sh
openclaw doctor || exit 1
openclaw status | grep -q "running" || exit 2
echo "OK"
Schedule via cron or systemd timer. Alert on non-zero exit.
HTTP probe pattern
# Illustrative — confirm paths in official Prism/API docs
curl -sf http://127.0.0.1:18789/health -H "Authorization: Bearer $OPENCLAW_TOKEN"
Never expose without auth/Tailscale (network security).
Webhook trigger sketch
External system (GitHub, Stripe, PagerDuty) POSTs to a small relay you control → relay validates signature → calls OpenClaw CLI/API to enqueue agent task → agent responds on Slack/Telegram.
Dev workflows: developer automations.
Log tail alert
openclaw logs --follow | grep -E "ERROR|CRITICAL" | while read line; do
# send to pager/email
echo "$line"
done
Production: use proper log stack — monitoring hands-on.