NovelClaw exposes a token-authenticated REST API for CLI agents and automation. The API does not use browser sessions or CSRF tokens.
Set an agent token in apps/novelclaw/.env:
APP_AGENT_API_KEY=change-this-agent-api-key
WEB_MODELLESS_MODE=0Then restart the NovelClaw service:
docker compose restart novelclawUse either header style:
X-API-Key: change-this-agent-api-key
Authorization: Bearer change-this-agent-api-keyList providers:
curl -H "X-API-Key: $APP_AGENT_API_KEY" \
http://127.0.0.1:8012/api/v1/providersSave a provider key:
curl -X POST http://127.0.0.1:8012/api/v1/providers/deepseek/api-key \
-H "X-API-Key: $APP_AGENT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"api_key":"sk-..."}'Register an OpenAI-compatible local provider:
curl -X POST http://127.0.0.1:8012/api/v1/providers \
-H "X-API-Key: $APP_AGENT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"slug": "local_llm",
"label": "Local LLM",
"base_url": "http://host.docker.internal:1234/v1",
"model": "local-model",
"wire_api": "chat",
"api_key": "local"
}'Create and start a story:
curl -X POST http://127.0.0.1:8012/api/v1/stories \
-H "X-API-Key: $APP_AGENT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"provider": "deepseek",
"premise": "Write a long-form mystery about an archivist who discovers a living map.",
"preferred_language": "en",
"requested_chapters": 3,
"start": true
}'Poll status:
curl -H "X-API-Key: $APP_AGENT_API_KEY" \
http://127.0.0.1:8012/api/v1/stories/1List chapters:
curl -H "X-API-Key: $APP_AGENT_API_KEY" \
http://127.0.0.1:8012/api/v1/stories/1/chaptersDownload the manuscript:
curl -L -H "X-API-Key: $APP_AGENT_API_KEY" \
-o story_1.txt \
http://127.0.0.1:8012/api/v1/stories/1/exportGET /api/v1/healthGET /api/v1/providersPOST /api/v1/providersPOST /api/v1/providers/{provider}/api-keyPOST /api/v1/storiesGET /api/v1/stories/{story_id}POST /api/v1/stories/{story_id}/startPOST /api/v1/stories/{story_id}/cancelGET /api/v1/stories/{story_id}/chaptersGET /api/v1/stories/{story_id}/chapters/{chapter_no}GET /api/v1/stories/{story_id}/export