API Overview

The better-openclaw REST API lets you programmatically generate OpenClaw stacks, validate configurations, and browse available services and skill packs. Use it to build integrations, CI/CD pipelines, or custom UIs.

Base URL

The API is available at the web application's base URL. In development, that's typically:

http://localhost:3000/api

In production:

https://better-openclaw.dev/api

All endpoints are prefixed with /api followed by the version (currently /v1), giving you a full base URL of:

https://better-openclaw.dev/api/v1

Authentication

The public API endpoints (listing services, skill packs, and presets) do not require authentication. For stack generation endpoints, you need an API key.

Getting an API Key

Set the OPENCLAW_API_KEY environment variable in your deployment's .env file to enable authentication:

# .env
OPENCLAW_API_KEY=your-secret-api-key-here

Using the API Key

Pass the API key in the Authorization header:

curl -X POST https://better-openclaw.dev/api/v1/generate \
  -H "Authorization: Bearer your-secret-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{"preset": "researcher"}'

Public vs Protected Endpoints

EndpointAuth Required
GET /v1/healthNo
GET /v1/servicesNo
GET /v1/skillsNo
GET /v1/presetsNo
POST /v1/validateYes
POST /v1/generateYes
GET /v1/presets/:nameNo

Rate Limiting

The API enforces rate limits to prevent abuse:

Endpoint TypeLimitWindow
Read (GET)100 requestsPer minute
Write (POST)20 requestsPer minute
Generate5 requestsPer minute

Rate limit headers are included in every response:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 97
X-RateLimit-Reset: 1700000000

When rate limited, the API returns 429 Too Many Requests with a Retry-After header indicating when you can retry.

Response Format

All responses are JSON. Successful responses follow this structure:

{
  "ok": true,
  "data": { ... }
}

Error responses:

{
  "ok": false,
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Service 'invalid-service' does not exist",
    "details": { ... }
  }
}

Error Codes

HTTP StatusCodeDescription
400VALIDATION_ERRORInvalid request body or parameters
401UNAUTHORIZEDMissing or invalid API key
404NOT_FOUNDResource not found
409CONFLICTConflicting services selected
429RATE_LIMITEDToo many requests
500INTERNAL_ERRORUnexpected server error

Quick Example

# List all available services
curl https://better-openclaw.dev/api/v1/services | jq

# Generate a stack
curl -X POST https://better-openclaw.dev/api/v1/generate \
  -H "Authorization: Bearer $OPENCLAW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-stack",
    "preset": "researcher",
    "proxy": "caddy",
    "domain": "ai.example.com"
  }'

Next Steps