Send a message and stream the reply
POST
/api/channels/webchat/messageSends a visitor message and streams the response as Server-Sent Events.
Event names:
received— the message was stored.delta—{ text }, a chunk of the assistant's reply. Concatenate in order.message—{ body, sender }, the complete reply.handover—{ state }, a human is taking over or the reply needs approval.error—{ message }, the reply failed. The stream then closes.
A conversation in queued or human state emits only handover; poll GET /api/channels/webchat/events for what the operator says next.
Session token from POST /api/channels/webchat/session
Request body
messagestringrequiredThe visitor's message.
Responses
200An SSE stream of the reply.400The message is empty.401The session token is missing, expired or does not match.403The Origin is not on the widget's allowed-domains list.413The message is longer than 2000 characters.429Rate limited. Back off and retry.curl -X POST 'https://staging.useline.io/api/channels/webchat/message' \
-H "Authorization: Bearer $LINE_SESSION_TOKEN" \
-H 'Origin: https://example.com' \
-H 'Content-Type: application/json' \
-d '{
"message": "Do you offer UK mobile numbers?"
}'Response 200
event: received
data: {"ok":true}
event: delta
data: {"text":"Yes — "}
event: message
data: {"body":"Yes — every Line number is a real UK number.","sender":"agent","turn":1}