opboxDocs
Sign inBook a demo
DocsAPI EndpointsAI - Reference

AI API Endpoints

Every AI-related HTTP endpoint, by surface area. Auth column shows what the endpoint accepts: Session (logged-in user cookie), MCP (Authorization: Bearer cp_live_...), or Cron (Authorization: Bearer $CRON_SECRET).

Chat

MethodEndpointAuthPurpose
POST/api/ai/chatSessionSSE-streaming chat with tool calls.
POST/api/integrations/ai/executeSessionOne-shot AI execute used by automation AI steps and the workflow builder test button.

Chat Threads

MethodEndpointAuthPurpose
GET/api/ai/chatsSessionList chat threads for the current user.
POST/api/ai/chatsSessionCreate a new thread.
GET/api/ai/chats/:idSessionGet a thread with metadata.
PATCH/api/ai/chats/:idSessionUpdate (rename / archive).
DELETE/api/ai/chats/:idSessionDelete a thread + all messages.
GET/api/ai/chats/:id/messagesSessionList messages in a thread.
POST/api/ai/chats/:id/messagesSessionPersist messages.

Saved Prompts (Skills)

MethodEndpointAuthPurpose
GET/api/ai/skillsSessionList per-user skills (KB-backed).
POST/api/ai/skillsSessionCreate a skill. Title up to 120 chars, content up to 5000.
DELETE/api/ai/skills/:idSessionDelete a skill.
POST/api/ai/skills/:idSessionMark used (no-op, kept for compat).

Transcripts

MethodEndpointAuthPurpose
POST/api/ai/transcribeSessionUpload audio + transcribe. Multipart form.
GET/api/ai/transcriptsSessionList the current user's transcripts.
GET/api/ai/transcripts/:idSessionGet a transcript.
DELETE/api/ai/transcripts/:idSessionDelete.

Passport OCR

MethodEndpointAuthPurpose
POST/api/ai/passport-ocrSessionAI vision passport extraction.

BYOK Credentials

MethodEndpointAuthRolesPurpose
GET/api/settings/ai-config/personalSessionMemberPersonal BYOK row + active org policy.
PATCH/api/settings/ai-config/personalSessionMemberUpsert personal BYOK. 403 when org disables personal keys.
DELETE/api/settings/ai-config/personalSessionMemberClear personal BYOK.
GET/api/settings/ai-configSessionOWNER/ADMINWorkspace-level override.
POST/api/settings/ai-configSessionOWNERLegacy extraction-pipeline endpoint (with verifyApiKey).
PATCH/api/settings/ai-configSessionOWNER/ADMINUpdate workspace override.
DELETE/api/settings/ai-configSessionOWNER/ADMINClear workspace override.
GET/api/organizations/[orgId]/ai-configSessionOWNER/ADMINOrg-level primary BYOK + allowPersonalKeys.
PUT/api/organizations/[orgId]/ai-configSessionOWNER/ADMINUpdate org config (incl. allowPersonalKeys).
DELETE/api/organizations/[orgId]/ai-configSessionOWNERClear org config.
GET/api/ai/modelsSession-Live model catalogue (proxies provider /v1/models, 5-min cache).
POST/api/settings/ai-config/openclaw/test-fireSessionOWNER/ADMINProbe the saved OpenClaw gateway: GET /health + POST /v1/chat/completions. Returns structured result with status / duration / body for each probe + a one-line summary. Surfaces the today-typical 404 (endpoint not implemented) clearly.
POST/api/settings/ai-config/hermes/test-fireSessionOWNER/ADMINProbe the saved Hermes gateway: GET /v1/models + POST /v1/chat/completions. The endpoint must be the tenant base URL, e.g. https://gateway.opbox.app/tenant/classical-visas, not the host root.

Agent Tasks (Bridge - MCP API Key Auth)

MethodEndpointAuthPurpose
POST/api/agent-tasks/[taskId]/claimMCPAtomic claim. Returns claimToken + autonomy level.
PATCH/api/agent-tasks/[taskId]/progressMCPUpdate progressText. Requires claimToken.
PATCH/api/agent-tasks/[taskId]/completeMCPTransition to DONE/FAILED. Accepts result + cost + duration.

Agent Tasks (Admin - Session Auth)

MethodEndpointAuthRolesPurpose
GET/api/agent-tasksSessionOWNER/ADMINList tasks.
POST/api/agent-tasksSessionOWNER/ADMINCreate manual task.
GET/api/agent-tasks/[taskId]SessionOWNER/ADMINFull task details.
PATCH/api/agent-tasks/[taskId]SessionOWNER/ADMINCancel.
POST/api/agent-tasks/[taskId]/retrySessionOWNER/ADMINRetry FAILED/TIMED_OUT.

Agent API Keys

MethodEndpointAuthRolesPurpose
GET/api/agent/api-keysSessionOWNER/ADMINList MCP keys (masked).
POST/api/agent/api-keysSessionOWNER/ADMINMint a key. Returns cleartext once.
PATCH/api/agent/api-keys/[id]SessionOWNER/ADMINUpdate name / autonomy / disabled state.
DELETE/api/agent/api-keys/[id]SessionOWNER/ADMINRevoke.

MCP Bridge

MethodEndpointAuthPurpose
GET/api/mcp/healthMCPLiveness + key summary.
GET/api/mcp/tools/listMCPLazy catalogue (~5KB). Pass ?mode=full for the full payload.
POST/api/mcp/tools/callMCP or OpenClaw bearerExecute a tool. JSON body with name and arguments. The bearer auth resolver tries cp_live_* first; on miss, falls back to OpenClaw bearer hash lookup (bidirectional auth).
GET/api/mcp/catalogue/fingerprintNonePublic stable SHA-256 of the live tool catalogue.
GET/api/mcp/catalogue/diffSessionAdmin: diff against last snapshot.
GET/api/mcp/catalogue/snapshotsSessionAdmin: list snapshots.

Doc Generation

MethodEndpointAuthPurpose
POST/api/documents/packs/[packId]/generateSessionGenerate. Coverage FAIL returns 422.
POST/api/documents/packs/[packId]/previewSessionPreview without writing.
GET/api/documents/generated/[id]SessionGenerated doc metadata + snapshot.
GET/api/documents/generated/[id]/downloadSessionStream the rendered DOCX.
GET/api/documents/doc/[id]/bookmarksSessionList bookmarks.
DELETE/api/documents/doc/[id]/bookmarks/[name]SessionRemove a bookmark (markers only).
GET/api/documents/doc/[id]/stylesSessionWord paragraph styles.
GET/api/settings/agent-configSessionOWNER/ADMIN: doc-gen agent config (cloud-fire + kill-switch).
PUT/api/settings/agent-configSessionOWNER/ADMIN: update.
POST/api/settings/agent-config/test-fireSessionOWNER/ADMIN: test the cloud-fire dispatch.

RAG

MethodEndpointAuthRolesPurpose
GET/api/admin/ragSessionOWNER/ADMINStatus + stats. ?sourceType=... filters.
POST/api/admin/ragSessionOWNERTrigger backfill. JSON body with sourceType (omit to backfill all types).
GET/api/docs/searchSession-Search system docs (powers search_system_docs).
POST/api/docs/embedSessionOWNER/ADMINEmbed system docs.

Cost Control

MethodEndpointAuthRolesPurpose
GET/api/settings/ai-usageSessionOWNER/ADMINUsage data. ?view=summary for spend breakdown.
POST/api/settings/ai-usage/reconcileSessionOWNERRun reconcileBudgetSnapshot() for current month.

Identity & Files

MethodEndpointAuthPurpose
POST/api/files/[fileId]/request-accessSessionRequest cross-workspace access.
GET/api/files/shared/[fileId]?grantId=...SessionStream a granted file.
GET/api/oversight/identitiesSessionSearch global profiles (workspace + overseer model).
GET/api/oversight/identities/[id]SessionSingle profile + risk + audit.

Security Events

MethodEndpointAuthRolesPurpose
GET/api/admin/security-eventsSessionOWNERQuery the security event log.

Cron-Triggered AI Work

MethodEndpointAuthPurpose
POST/api/cron/verify-ai-keysCronProbe stored BYOK keys against /v1/models?limit=1; clear keyVerifiedAt on 401/403.
POST/api/cron/tool-catalogue-notifyCronDaily 04:00 UTC - page workspace OWNERs on structural catalogue changes.
POST/api/cron/retry-background-jobsCronRetry compliance-critical fire-and-forget jobs (incl. some AI side effects).

All cron endpoints share a timing-safe auth helper - they 401 on missing or wrong CRON_SECRET.

Auth Headers

Standard NextAuth session cookie. CSRF token required for non-GET methods (x-csrf-token header from useCsrf() hook).

MCP (Bearer)

Authorization: Bearer cp_live_...
X-MCP-Client: claude-code

X-MCP-Client is mandatory; missing it returns 400. Browsers can't set it cross-origin, which blocks compromised browser sessions from invoking MCP even with a stolen key.

Cron (Bearer)

Authorization: Bearer $CRON_SECRET

CRON_SECRET is stored as a Fly secret. Compared timing-safe via crypto.timingSafeEqual.

See Also

We use cookies

Strictly necessary cookies keep you signed in and protect requests. We also use optional cookies for preferences and (when enabled) analytics. Learn more.