POST
/forms/:id/analytics-chatAnalytics Chat
Conversational AI Q&A about form response data
Scope: ANALYTICS_READ
Overview
Ask questions about your form's response data using natural language. Supports two response modes: standard JSON or real-time Server-Sent Events (SSE) streaming. Sessions are maintained in-memory for multi-turn conversations.
Plan Requirement
Analytics Chat requires a Pro plan or higher and consumes AI credits per message.
Request
POST
/forms/:id/analytics-chatPath Parameters
Headers
| Header | Value |
|---|---|
Authorization | Bearer fxk_live_<your-api-key> |
Content-Type | application/json |
Accept | application/json (default) or text/event-stream (for SSE streaming) |
Request Body
Example Request
JSON Mode (default)
curl -X POST "https://api.formfex.com/api/v1/public/forms/FORM_ID/analytics-chat" \
-H "Authorization: Bearer $FORMFEX_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "message": "What is the average completion rate?" }'SSE Streaming Mode
curl -X POST "https://api.formfex.com/api/v1/public/forms/FORM_ID/analytics-chat" \
-H "Authorization: Bearer $FORMFEX_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{ "message": "Summarize the response trends" }'Response — JSON Mode
Response — SSE Streaming Mode
The response is a text/event-stream with the following event types:
session — First event, provides the session ID
event: session
data: {"sessionId":"s1a2b3c4-d5e6-4f7a-8b9c-0d1e2f3a4b5c"}
chunk — Streamed text fragments
event: chunk
data: {"content":"The average completion rate"}
event: chunk
data: {"content":" across all responses is 87.3%."}
done — Final event with metadata
event: done
data: {"suggestedActions":[...],"creditsUsed":2}
error — Sent if processing fails
event: error
data: {"message":"Chat stream failed"}
Continuing a Conversation
Pass the sessionId from the first response to continue the conversation:
const followUp = await fetch(
"https://api.formfex.com/api/v1/public/forms/FORM_ID/analytics-chat",
{
method: "POST",
headers: {
Authorization: "Bearer " + API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
message: "Which field has the highest skip rate?",
sessionId: "s1a2b3c4-d5e6-4f7a-8b9c-0d1e2f3a4b5c",
}),
}
)Error Cases
| Status | Condition |
|---|---|
402 | Feature not available on current plan or insufficient AI credits |
404 | Session ID not found (session expired or invalid) |
403 | Session belongs to a different user or form |
429 | AI endpoint rate limit exceeded or per-user session cap reached |
503 | Global session capacity reached (try again later) |
Session Lifetime
Chat sessions are stored in memory and expire after 30 minutes of inactivity. After expiry, start a new session by omitting the sessionId. Conversation history is limited to the last 10 messages.