iotoms Docs

Ask a question about your business data

POST
/api/v1/ai/chat/stream

Answers a plain-English question about the tenant's report data and streams the answer back as server-sent events. An optional history of up to 6 earlier turns gives the conversation context.

How to use it

  1. Send the question as query (at most 500 characters), with context giving today's date and timezone so relative dates resolve correctly.
  2. For a follow-up, include up to 6 earlier turns in history, oldest first.
  3. Read the text/event-stream response: TOKEN events carry answer text to show as it arrives, TOOL_CALL and TOOL_CARD events show which data was looked up, and DONE or ERROR ends the stream. Nothing is saved: the assistant only reads data the caller is allowed to see, and an item it drafts is added only after it is confirmed.

Authorization

BearerAuth
headerAuthorizationBearer <JWT>

Header Parameters

Request Body

application/json
  1. body
query*string

The question in plain English, e.g. "top 5 items by sales last week". Required, at most 500 characters.

Length0 <= length <= 500
context?

Optional date and timezone of the person asking, used to resolve words like "today" or "this month".

history?array<>|

Optional earlier turns of the same conversation, oldest first, at most 6. Lets follow-up questions refer to earlier ones. Nothing is stored server-side.

Items0 <= items <= 6

Response Body

OK

text/event-stream
  1. response
timeout?|

Server-side lifetime of the event stream in milliseconds (300000, i.e. 5 minutes). You do not send this; the response body is a text/event-stream of answer events.

Formatint64
Example Request
curl -X POST 'https://beta.iotoms.com/api/v1/ai/chat/stream' \  -H 'Content-Type: application/json' \  -d '{  "query": "string"}'
Example Response
{  "timeout": 0}