# OpenClaw as a Service API Production base URL: https://openclaw-as-a-service.com API root: https://openclaw-as-a-service.com/api If this document was fetched from another host, use that host as the base URL instead. ## Authentication All private endpoints require: `Authorization: Bearer YOUR_API_KEY` Create keys at: https://openclaw-as-a-service.com/account ## Core workflow 1. Discover resources: `GET /api` 2. List instances: `GET /api/instances` 3. Create an instance when subscription or invite access allows it: `POST /api/instances` 4. Create or reuse a chat session: `POST /api/instances/{instanceId}/chat/sessions` 5. Send a message: - synchronous: `POST /api/instances/{instanceId}/chat` - streaming SSE: `POST /api/instances/{instanceId}/chat/stream` 6. Read recent history: - `GET /api/instances/{instanceId}/chat/messages?session_id=...&tail=true&limit=N` - `GET /api/instances/{instanceId}/chat/events?session_id=...&after=...` 7. Control the workspace: - terminal exec: `POST /api/instances/{instanceId}/terminal/exec` - terminal websocket: `GET /api/instances/{instanceId}/terminal/ws` - files list/read/write/upload: `/files`, `/files/read`, `/files/write`, `/files/upload` ## Minimal examples ### Discover API root ```bash curl -s https://openclaw-as-a-service.com/api ``` ### List instances ```bash curl -s https://openclaw-as-a-service.com/api/instances \ -H "Authorization: Bearer YOUR_API_KEY" ``` ### Create instance ```bash curl -X POST https://openclaw-as-a-service.com/api/instances \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"invite_code":"YOUR_INVITE_CODE_IF_NEEDED"}' ``` ### Send chat message ```bash curl -X POST https://openclaw-as-a-service.com/api/instances/INSTANCE_ID/chat \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"message":"Inspect /workspace and summarize what you find."}' ``` ### Stream chat message ```bash curl -N -X POST https://openclaw-as-a-service.com/api/instances/INSTANCE_ID/chat/stream \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"message":"Continue from the last task."}' ``` ### Execute terminal command ```bash curl -X POST https://openclaw-as-a-service.com/api/instances/INSTANCE_ID/terminal/exec \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"command":"pwd","timeout_ms":5000}' ``` ### Read file ```bash curl -G https://openclaw-as-a-service.com/api/instances/INSTANCE_ID/files/read \ --data-urlencode "path=/workspace/README.md" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ## Realtime endpoints - Chat events SSE: `GET /api/instances/{instanceId}/chat/events` - Terminal websocket: `GET /api/instances/{instanceId}/terminal/ws` - Desktop websocket: `GET /api/instances/{instanceId}/vnc/ws` ## Agent artifacts - Interactive docs: https://openclaw-as-a-service.com/docs - OpenAPI JSON: https://openclaw-as-a-service.com/api/openapi.json - OpenAPI YAML: https://openclaw-as-a-service.com/api/openapi.yaml - Extended guide: https://openclaw-as-a-service.com/llms-full.md - Agent guide: https://openclaw-as-a-service.com/agent.md - Skill bundle: https://openclaw-as-a-service.com/skills/openclaw-api-control/SKILL.md