API Server (pocketpaw serve)

The pocketpaw serve command starts PocketPaw as a headless API server without the web dashboard frontend. It exposes the full REST API and WebSocket endpoints, making it ideal for:

  • The desktop client (Tauri app) connecting over localhost
  • Custom scripts and automation
  • External integrations that only need the API
  • Docker and headless server deployments

Quick Start

Terminal window
# Start the API server (default: localhost:8888)
pocketpaw serve
# Custom host and port
pocketpaw serve --host 0.0.0.0 --port 9000
# Development mode with auto-reload
pocketpaw serve --dev

What’s Included

The API server starts the full PocketPaw backend:

ComponentStatus
REST API (/api/v1/)Active
WebSocket (/ws, /api/v1/ws)Active
Message busActive
Agent loopActive
Memory systemActive
SchedulerActive
Channel adaptersActive (if configured)
Web dashboard UINot served

The only difference from the default pocketpaw command is that no HTML/CSS/JS frontend is served. All API endpoints work identically.

Authentication

The API server supports multiple authentication methods:

Master Token

On first run, PocketPaw generates a master access token saved at ~/.pocketpaw/access_token. Use it as a Bearer token:

Terminal window
curl -H "Authorization: Bearer YOUR_TOKEN" http://localhost:8888/api/v1/health

Session Tokens

Exchange the master token for a short-lived session token:

Terminal window
# Get a session token
curl -X POST http://localhost:8888/api/v1/auth/session \
-H "Authorization: Bearer YOUR_MASTER_TOKEN"
# Response: { "session_token": "uuid:hmac_signature" }

API Keys

Create scoped API keys for long-lived access:

Terminal window
# Create an API key
curl -X POST http://localhost:8888/api/v1/auth/api-keys \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "my-script", "scopes": ["chat", "sessions"]}'
# Response includes the key (shown once): { "key": "pp_xxxx...", "id": "..." }

OAuth2 (PKCE)

For desktop and third-party apps, use the OAuth2 PKCE flow:

  1. GET /api/v1/oauth/authorize?client_id=...&code_challenge=...
  2. User approves consent
  3. POST /api/v1/oauth/token with authorization code
  4. Use the returned access token (ppat_* prefix)

Localhost Bypass

By default, requests from 127.0.0.1 or ::1 skip authentication. Disable this with:

Terminal window
export POCKETPAW_LOCALHOST_AUTH_BYPASS=false

API Endpoints

All endpoints are prefixed with /api/v1/. Here’s a summary by category:

Chat

MethodEndpointDescription
POST/chatSend message, get complete response (blocking)
POST/chat/streamSend message, receive SSE stream
POST/chat/stopCancel in-flight response

Sessions

MethodEndpointDescription
POST/sessionsCreate new session
GET/sessionsList sessions (paginated)
DELETE/sessions/{id}Delete session
POST/sessions/{id}/titleUpdate session title
GET/sessions/searchSearch sessions by content
GET/sessions/{id}/historyGet message history
GET/sessions/{id}/exportExport as JSON or Markdown

Settings

MethodEndpointDescription
GET/settingsGet current settings
PUT/settingsUpdate settings

Memory

MethodEndpointDescription
GET/memory/long_termGet long-term memories (paginated)
DELETE/memory/long_term/{id}Delete memory entry
GET/memory/settingsGet memory backend config
POST/memory/settingsSave memory backend config
GET/memory/statsGet memory statistics

Health & Diagnostics

MethodEndpointDescription
GET/versionVersion and backend info
GET/healthHealth engine summary
GET/health/errorsRecent errors (paginated)
POST/health/checkTrigger health check
GET/auditAudit log entries
POST/security-auditRun security audit
GET/metrics/systemCPU, RAM, disk, battery
GET/metrics/usageToken usage and costs

Identity

MethodEndpointDescription
GET/identityGet all identity files
PUT/identitySave identity file edits

Channels

MethodEndpointDescription
GET/channels/statusStatus of all channel adapters
POST/channels/saveSave channel configuration
POST/channels/toggleStart or stop a channel

MCP Servers

MethodEndpointDescription
GET/mcp/statusStatus of MCP servers
POST/mcp/addAdd MCP server
POST/mcp/removeRemove MCP server
POST/mcp/toggleToggle MCP server
POST/mcp/testTest connection
GET/mcp/presetsList presets
POST/mcp/presets/installInstall preset

Skills

MethodEndpointDescription
GET/skillsList installed skills
GET/skills/searchSearch skill library
POST/skills/installInstall skill
POST/skills/removeRemove skill

Reminders & Intentions

MethodEndpointDescription
GET/remindersList reminders
POST/remindersCreate reminder (natural language)
DELETE/reminders/{id}Delete reminder
GET/intentionsList intentions
POST/intentionsCreate intention
POST/intentions/{id}/toggleToggle intention

Backends

MethodEndpointDescription
GET/backendsList backends with availability
POST/backends/installInstall backend SDK

Kits (Command Centers)

MethodEndpointDescription
GET/kits/catalogList kit catalog
POST/kits/catalog/{id}/installInstall kit
GET/kitsList installed kits
DELETE/kits/{id}Uninstall kit
POST/kits/{id}/activateActivate kit

Files

MethodEndpointDescription
GET/files/browseList directory contents
GET/files/contentGet file content
GET/files/recentRecently accessed files

Remote Access

MethodEndpointDescription
GET/remote/statusTunnel status
POST/remote/startStart Cloudflare tunnel
POST/remote/stopStop tunnel

Events (SSE)

MethodEndpointDescription
GET/events/streamSubscribe to real-time system events

WebSocket

Connect to the WebSocket for real-time streaming:

const ws = new WebSocket('ws://localhost:8888/api/v1/ws?token=YOUR_TOKEN');
// Send a chat message
ws.send(JSON.stringify({
type: 'chat',
content: 'Hello, PocketPaw!',
session_id: 'my-session'
}));
// Receive streaming responses
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
// data.type: 'chunk', 'stream_end', 'tool_start', 'tool_result', 'thinking', 'error'
};

WebSocket paths: /ws, /api/v1/ws, /v1/ws (all equivalent).

Comparison: serve vs Default Mode

pocketpaw (default)pocketpaw serve
Web dashboardServed at rootNot served
REST API/api/v1//api/v1/
WebSocketAvailableAvailable
Auto-opens browserYesNo
All backend servicesRunningRunning
Best forBrowser-based usageDesktop app, scripts, headless

OpenAPI Documentation

When the API server is running, interactive API docs are available at:

  • Swagger UI: http://localhost:8888/api/v1/docs
  • ReDoc: http://localhost:8888/api/v1/redoc
  • OpenAPI JSON: http://localhost:8888/api/v1/openapi.json