Developer / REST API reference
The authoritative WebChat AI programmatic surface. All requests use JSON over HTTPS and execute with strict multi-tenant isolation.
The WebChat AI API accepts JSON request payloads and returns JSON responses. Timestamps are formatted according to ISO 8601 (YYYY-MM-DDTHH:MM:SSZ).
NEXT_PUBLIC_API_URL.Authorization: Bearer <jwt_access_token> header.X-API-Key: <secret_key> header for backend integration.POST, PATCH, DELETE) must supply the x-csrf-token header.Create a new assistant in website, files (upload-only), or mixed mode.
curl -X POST "https://api.webchat.ai/api/websites" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Docs Assistant",
"url": "https://docs.acme.com",
"source_mode": "mixed"
}'Response (201 Created):
{
"id": "673f4a12bc90ef1234567890",
"tenant_id": "tenant_98765",
"name": "Acme Docs Assistant",
"url": "https://docs.acme.com",
"source_mode": "mixed",
"status": "pending",
"pages_indexed": 0,
"widget_id": "wgt_ab8901cd",
"knowledge_status": "empty",
"knowledge_documents": 0,
"knowledge_chunks": 0,
"created_at": "2026-09-16T12:00:00Z",
"updated_at": "2026-09-16T12:00:00Z"
}Upload up to 5 files (.pdf, .docx, .md, .txt) totaling under 10 MB.
curl -X POST "https://api.webchat.ai/api/knowledge/websites/673f4a12bc90ef1234567890/documents/upload" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-F "files=@spec-sheet.pdf" \
-F "files=@faq-guide.docx"Response (201 Created):
{
"website_id": "673f4a12bc90ef1234567890",
"uploaded": [
{
"id": "doc_101",
"website_id": "673f4a12bc90ef1234567890",
"file_name": "spec-sheet.pdf",
"file_size_bytes": 1048576,
"mime_type": "application/pdf",
"status": "pending",
"char_count": 0
},
{
"id": "doc_102",
"website_id": "673f4a12bc90ef1234567890",
"file_name": "faq-guide.docx",
"file_size_bytes": 262144,
"mime_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"status": "pending",
"char_count": 0
}
]
}Initiates crawler discovery starting from the registered root URL.
curl -X POST "https://api.webchat.ai/api/websites/673f4a12bc90ef1234567890/crawl" \
-H "Authorization: Bearer $ACCESS_TOKEN"Response (202 Accepted):
{
"job_id": "crawl_89f029",
"website_id": "673f4a12bc90ef1234567890",
"status": "queued",
"pages_discovered": 1,
"pages_indexed": 0,
"started_at": "2026-09-16T12:05:00Z"
}Structured error codes returned in the standard response envelope: { error: { code, message } }.
| Status | Codes |
|---|---|
| 400 Bad Request | INVALID_URLEMBEDDING_UNAVAILABLEEMBEDDING_INCOMPATIBLEINVALID_QUESTIONGENERATION_UNAVAILABLESPAM_REJECTEDDOCUMENT_TOO_LARGEUNSUPPORTED_MEDIA_TYPE |
| 401 Unauthorized | INVALID_CREDENTIALSINVALID_TOKENTOKEN_EXPIREDTOKEN_REUSE_DETECTED |
| 403 Forbidden | ACCOUNT_SUSPENDEDEMAIL_NOT_VERIFIEDFORBIDDENCSRF_FAILEDWIDGET_DISABLEDWIDGET_ORIGIN_NOT_ALLOWEDWIDGET_DOMAIN_NOT_CONFIGURED |
| 404 Not Found | WEBSITE_NOT_FOUNDCRAWL_JOB_NOT_FOUNDDOCUMENT_NOT_FOUNDSESSION_NOT_FOUNDWIDGET_NOT_FOUNDAPI_KEY_NOT_FOUNDMESSAGE_NOT_FOUNDTENANT_NOT_FOUND |
| 409 Conflict | EMAIL_ALREADY_EXISTSWEBSITE_ALREADY_EXISTSCRAWL_IN_PROGRESSWEBSITE_NOT_READY |
| 422 Unprocessable | INSUFFICIENT_CONTENTVALIDATION_ERROR |
| 429 Too Many Requests | AI_QUOTA_EXCEEDEDRATE_LIMIT_EXCEEDEDMESSAGE_LIMIT_REACHEDLIMIT_REACHED |
| 500 Internal Error | PROVIDER_CONFIGURATION |
| 502 Bad Gateway | EMBEDDING_FAILEDGENERATION_FAILEDPAYMENT_PROVIDER_ERROR |
| 503 Unavailable | SERVICE_UNAVAILABLE |
Probes for container orchestration and uptime monitoring.
| Method | Endpoint Path | Description |
|---|---|---|
| GET | /api/health/live | Lightweight liveness probe (200). |
| GET | /api/health | Comprehensive health check reporting database and cache connectivity. |
| GET | /api/health/ready | Readiness probe for load balancers. |
Register assistants, configure ingestion modes, and trigger background crawls.
| Method | Endpoint Path | Description |
|---|---|---|
| POST | /api/websites | Register a new website or document-only assistant (201). |
| GET | /api/websites | List all registered assistants for the authenticated tenant. |
| GET | /api/websites/{websiteId} | Get assistant metadata, crawl status, and knowledge chunk counts. |
| PATCH | /api/websites/{websiteId} | Update assistant name, root URL, or source mode. |
| DELETE | /api/websites/{websiteId} | Permanently remove an assistant and all associated documents/vectors. |
| POST | /api/websites/{websiteId}/crawl | Trigger an asynchronous web crawl job for the root URL (202). |
Upload files (.pdf, .docx, .md, .txt), monitor chunking, and retry failed embeddings.
| Method | Endpoint Path | Description |
|---|---|---|
| GET | /api/knowledge/websites/{websiteId}/documents | List documents for an assistant with processing statuses and summaries. |
| POST | /api/knowledge/websites/{websiteId}/documents/upload | Upload up to 5 documents (max 10 MB total) via multipart/form-data (201). |
| POST | /api/knowledge/documents/{documentId}/retry | Re-queue text extraction and embedding generation for a failed document. |
| DELETE | /api/knowledge/documents/{documentId} | Permanently delete a document, its extracted text, and vector embeddings. |
Track background sitemap discovery and page extraction jobs.
| Method | Endpoint Path | Description |
|---|---|---|
| GET | /api/crawl-jobs/{jobId} | Poll crawl job status, pages discovered, and pages indexed. |
| GET | /api/crawl-jobs/{jobId}/stream | Server-Sent Events (SSE) stream providing real-time crawl event updates. |
Manage visual appearance, theme presets, font families, and domain allowlists.
| Method | Endpoint Path | Description |
|---|---|---|
| GET | /api/websites/{websiteId}/widget | Fetch the active widget configuration and authoritative embed snippet. |
| PATCH | /api/websites/{websiteId}/widget | Update theme preset, custom colors, font, bot branding, and allowed domains. |
Access visitor conversation history, source citations, and latency telemetry.
| Method | Endpoint Path | Description |
|---|---|---|
| GET | /api/conversations | List visitor conversations with filtering by website, query, and status. |
| GET | /api/conversations/{sessionId} | Retrieve full conversation transcript, token metrics, and cited URLs. |
| DELETE | /api/conversations/{sessionId} | Permanently delete a visitor conversation session and messages. |
Aggregated metrics, query frequency, response time histograms, and feedback.
| Method | Endpoint Path | Description |
|---|---|---|
| GET | /api/analytics/summary?days={n} | Headline KPIs including total messages, sessions, response times, and costs. |
| GET | /api/analytics/overview?days={n} | Aggregated overview metrics comparing against prior window. |
| GET | /api/analytics/timeseries?days={n} | Daily message and active conversation timeseries data. |
| GET | /api/analytics/top-websites?days={n} | Activity rankings across registered assistants in your account. |
| GET | /api/analytics/questions?days={n}&limit=10 | Most frequently asked visitor questions and satisfaction ratings. |
| GET | /api/analytics/performance?days={n} | Response time percentile breakdowns (p50, p90, p99). |
| GET | /api/analytics/feedback?days={n} | Sentiment breakdown of helpful vs unhelpful responses. |
Visitor sentiment scores and verbatim user comments.
| Method | Endpoint Path | Description |
|---|---|---|
| GET | /api/feedback | List recent visitor feedback entries. |
| GET | /api/feedback/summary?days={n} | Compact positive vs negative satisfaction percentage summary. |
Plan catalog, quota consumption, invoices, and checkout sessions.
| Method | Endpoint Path | Description |
|---|---|---|
| GET | /api/billing/plans | List available subscription plans. |
| GET | /api/billing/subscription | Get current active subscription and payment history. |
| GET | /api/billing/usage | Current month usage vs plan limits. |
| POST | /api/billing/checkout | Create a Stripe/payment checkout session for tier upgrades (201). |
Generate and revoke API keys for headless server-to-server operations.
| Method | Endpoint Path | Description |
|---|---|---|
| POST | /api/api-keys | Create a new scoped API key (201). Secret is displayed only once. |
| GET | /api/api-keys | List existing API keys with last-used timestamps. |
| DELETE | /api/api-keys/{keyId} | Instantly revoke an API key. |
Building Headless Integrations
X-API-Key header.Related documentation
Ready to build?
Register a website and get a live assistant in minutes.