Skip to main content
POST
/
chat
cURL
curl --request POST \
  --url https://www.greenflash.ai/api/v1/chat \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "question": "What are the top complaints from enterprise customers this week?",
  "messages": [
    {
      "role": "user",
      "content": "Show me sentiment trends for the support bot."
    },
    {
      "role": "assistant",
      "content": "Based on the last 30 days, sentiment is trending slightly negative (-0.08). The main driver is billing-related frustration, which accounts for 34% of negative conversations."
    }
  ],
  "conversationId": "conv-abc-123",
  "context": "Focus on the Customer Support Bot product.",
  "productId": "123e4567-e89b-12d3-a456-426614174000"
}
'
{
  "success": false,
  "error": "Validation error: question must be between 1 and 4000 characters"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
question
string
required

The current user question to send to the AI agent.

Required string length: 1 - 4000
messages
object[]

Prior conversation history (NOT including the current question). Used for multi-turn context.

Maximum array length: 50
conversationId
string

Stable identifier for multi-turn conversations. If omitted, a new ID is generated.

Maximum string length: 128
context
string

Free-form hint injected into the system prompt for this turn only.

Maximum string length: 2000
productId
string<uuid>

Scope the chat to a specific product. If omitted, the agent can access all products.

Response

SSE stream of chat events (text/event-stream). See endpoint description for event format.

Example SSE stream:

event: tool_call
data: {"step":1,"toolName":"getConversations","displayName":"Searching conversations"}

event: tool_call
data: {"step":2,"toolName":"getUserRanking","displayName":"Ranking users by metrics"}

event: tool_result
data: {"step":1,"toolName":"getConversations","displayName":"Searching conversations"}

event: tool_result
data: {"step":2,"toolName":"getUserRanking","displayName":"Ranking users by metrics"}

event: text_delta
data: {"text":"Based on your"}

event: text_delta
data: {"text":" conversation data, the top complaints"}

event: text_delta
data: {"text":" from enterprise customers this week are..."}

event: done
data: {"conversationId":"conv-abc-123","status":"complete","usage":{"toolCalls":2,"tools":["getConversations","getUserRanking"]}}