Skip to content

feat(api): add message injection endpoint#19

Open
dathtd119 wants to merge 2 commits intomoazbuilds:masterfrom
dathtd119:feat/inject-api
Open

feat(api): add message injection endpoint#19
dathtd119 wants to merge 2 commits intomoazbuilds:masterfrom
dathtd119:feat/inject-api

Conversation

@dathtd119
Copy link
Copy Markdown
Contributor

@dathtd119 dathtd119 commented Mar 9, 2026

Summary

  • Adds POST /api/inject endpoint for external systems to inject messages into claudeclaw sessions via HTTP
  • Bearer token authentication via apiToken field in settings.json
  • Extends json() helper to support HTTP status codes

Use Case

Allows n8n workflows (or any external system) to programmatically send messages to a running claudeclaw daemon, replacing the need for a separate hook API.

Configuration

Add to settings.json:

{
  "apiToken": "your-secret-token-here"
}

API

curl -X POST http://127.0.0.1:4632/api/inject \
  -H "Authorization: Bearer your-secret-token-here" \
  -H "Content-Type: application/json" \
  -d '{"message": "Hello from external system"}'

Response: { "ok": true, "result": "...", "exitCode": 0 }

Files Changed

  • src/config.tsapiToken field in Settings
  • src/ui/http.tsjson() now accepts optional status code
  • src/ui/auth.ts — Bearer token validation (new)
  • src/ui/server.tsPOST /api/inject handler

Test plan

  • POST without token → 401 Unauthorized
  • POST with wrong token → 401 Unauthorized
  • POST with valid token, no message → 400 Bad Request
  • POST with valid token + message → 200 + assistant response
  • No apiToken in settings → 503 Service Unavailable

POST /api/inject allows external systems to inject messages into
claudeclaw sessions via HTTP. Requires apiToken in settings.json.
- POST /api/inject now auto-sends agent stdout to Telegram (first
  allowedUserId) after runUserMessage completes
- Add telegram.receiveEnabled config flag (default true); when false,
  daemon skips startPolling but keeps token available for sending.
  Allows send-only instances to share a bot token without 409 conflict.
Fenrur added a commit to Fenrur/claudeclaw that referenced this pull request Mar 13, 2026
- Add /api/inject POST endpoint for external message injection
- Add bearer token auth (apiToken in settings)
- Add receiveEnabled toggle for Telegram send-only mode
- json() helper accepts optional status parameter

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
justmaker pushed a commit to justmaker/claudeclaw that referenced this pull request Mar 31, 2026
- tsconfig.json 新增 strict: true 和 skipLibCheck: true
- 修復 5 個 type error(含先前 commit 已修的 3 個)
  - src/ui/server.ts: server.port 可能為 undefined,加 fallback
  - src/config.ts: parseSettings 參數數量不符(已在前次 commit 修復)
  - src/whisper.ts: Dirent 無 path 屬性(已在前次 commit 修復)
- bun run tsc --noEmit 零 error 通過
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant