API Reference
Overview

API Reference

The Agentbase REST API is served from the core NestJS backend at http://localhost:3001/api.

Interactive Swagger documentation is available at /api/docs when running in development mode.

Authentication

Most endpoints require a JWT bearer token:

# Register
POST /api/auth/register
{ "email": "user@example.com", "password": "secret", "displayName": "User" }
 
# Login
POST /api/auth/login
{ "email": "user@example.com", "password": "secret" }
# Returns: { "access_token": "eyJ...", "refresh_token": "eyJ..." }
 
# Use the token
GET /api/applications
Authorization: Bearer eyJ...

Core Endpoints

ResourceEndpoints
AuthPOST /auth/register, POST /auth/login, POST /auth/refresh, OAuth (GitHub/Google)
UsersGET /users/me, PUT /users/me, DELETE /users/me
ApplicationsGET /applications, POST /applications, GET/PUT/DELETE /applications/:id
ConversationsGET /conversations, POST /conversations, POST /conversations/:id/messages, stream
PluginsGET /plugins, GET /plugins/:id, install/activate/deactivate/configure per app
ThemesGET /themes, GET /themes/:id, set/customize per app
PromptsGET /prompts, POST /prompts, PUT/DELETE /prompts/:id
Model ConfigsGET /model-configs, POST /model-configs, versioning, A/B testing
AnalyticsGET /analytics/overview, usage metrics, conversation stats, cost tracking
API KeysGET /api-keys, POST /api-keys, DELETE /api-keys/:id
Provider KeysGET/PUT/DELETE /provider-keys/:provider, POST /provider-keys/:provider/validate
TeamsGET /teams, POST /teams, invite/remove members, role management
WebhooksGET /webhooks, POST /webhooks, PUT/DELETE /webhooks/:id, delivery logs
Marketplacebrowse, featured, reviews, submit, install (plugins + themes)
TemplatesGET /templates, POST /templates/:id/deploy
KnowledgePOST /knowledge (upload), GET /knowledge/search, per-app RAG documents
UploadsPOST /uploads, multipart file upload, S3-backed
Billingplans, POST /billing/subscribe, GET /billing/invoices, usage limits
BrandingGET/PUT /branding/:appId — logo, colors, custom CSS per application
Custom DomainsGET /custom-domains, POST /custom-domains, verify, activate
NotificationsGET /notifications, PUT /notifications/:id/read, mark all read
SSOSAML/LDAP configuration, POST /sso/saml/callback
WorkflowsGET /workflows, POST /workflows, trigger/pause/resume automated flows
AuditGET /audit — immutable audit log of admin and user actions
Data ExportPOST /data-export — export conversations, analytics, or user data as CSV/JSON
AdminGET /admin/users, GET /admin/marketplace, platform-level management (admin only)
System HealthGET /system-health — detailed system metrics (CPU, memory, DB, Redis)
Plugin EndpointsALL /plugins/:pluginId/endpoints/* — dynamic routes registered by plugins

Public API (Widget)

The embeddable widget uses API key authentication via the X-API-Key header:

POST /api/public/chat
X-API-Key: agb_...
{ "message": "Hello!", "applicationId": "..." }

BYOK — Bring Your Own Key

Users can securely store their own AI provider API keys and bypass the platform quota entirely. Keys are AES-256-GCM encrypted at rest and never returned in full.

# List saved provider keys (returns hints only, not the real keys)
GET /api/provider-keys
Authorization: Bearer <token>
# Returns: [{ "provider": "openai", "keyHint": "ab12", "isActive": true }, ...]
 
# Save or replace a key for a provider
PUT /api/provider-keys/:provider
Authorization: Bearer <token>
{ "apiKey": "sk-..." }
# provider: openai | anthropic | gemini | huggingface
 
# Remove a saved key
DELETE /api/provider-keys/:provider
Authorization: Bearer <token>
 
# Validate a key with a live test call
POST /api/provider-keys/:provider/validate
Authorization: Bearer <token>
# Returns: { "valid": true, "models": ["gpt-4", "gpt-3.5-turbo"] }

See Provider Keys API for full details.

AI Service Endpoints

The Python AI microservice (http://localhost:8000) exposes its own API under /api/ai:

EndpointDescription
GET /api/healthAI service health check
GET /api/ai/providersList all configured AI providers and their models
GET /api/ai/providers/:provider/modelsList models for a specific provider
POST /api/ai/conversationsCreate a new AI conversation (stored in MongoDB)
GET /api/ai/conversations/:idRetrieve conversation with full message history
POST /api/ai/conversations/:id/messagesSend a message and get an AI response
POST /api/ai/conversations/:id/streamSend a message and stream the response via SSE

The core NestJS API communicates with the AI service internally. Clients should generally use the core API at :3001 — the AI service endpoints are available for direct integration when needed.

Streaming (SSE)

POST http://localhost:8000/api/ai/conversations/{id}/stream
Content-Type: application/json
 
{
  "content": "Explain quantum entanglement simply.",
  "provider": "openai",
  "model": "gpt-4",
  "temperature": 0.7,
  "system_prompt": "You are a helpful assistant."
}

Response is a stream of Server-Sent Events:

data: {"type": "chunk", "content": "Quantum "}
data: {"type": "chunk", "content": "entanglement "}
data: {"type": "done", "fullResponse": "Quantum entanglement is..."}

Rate Limiting

API responses include rate limit headers:

  • X-RateLimit-Limit — max requests per window
  • X-RateLimit-Remaining — remaining requests
  • X-RateLimit-Reset — window reset timestamp