Send Message
POST /message
Sends a new message to the chat. Bearer JWT is required. The request body must be multipart/form-data.
Sending is done only through this REST call. Socket.IO is not used to send messages.
Request
POST /message HTTP/1.1
Host: widget-api.chatbot.aithinks.net
Authorization: Bearer <accessToken>
Content-Type: multipart/form-data
Form fields
| Field | Type | Description |
|---|---|---|
message | string | Text content. Required if there is no file |
file | binary | Optional file attachment |
Text message example
const form = new FormData();
form.append('message', 'Merhaba');
await fetch(`${BASE_URL}/message`, {
method: 'POST',
headers: {
Authorization: `Bearer ${accessToken}`,
// Content-Type'ı elle set etmeyin; browser boundary ekler
},
body: form,
});
File message example
const form = new FormData();
form.append('file', fileInput.files[0]);
form.append('message', 'Fatura görseli'); // opsiyonel caption / açıklama
await fetch(`${BASE_URL}/message`, {
method: 'POST',
headers: {
Authorization: `Bearer ${accessToken}`,
},
body: form,
});
Type selection
The server chooses the message type based on the uploaded file's MIME type:
| MIME group | Message type |
|---|---|
| image/* | IMAGE |
| video/* | VIDEO |
| audio/* | AUDIO |
| other | FILE |
| no file | TEXT |
Successful response
{
"success": true
}
The sent message appears in history. The bot/agent reply arrives via the Socket.IO message event.
Errors
| Status | Meaning |
|---|---|
400 | Invalid form (e.g. neither text nor file) |
401 | Invalid or missing JWT |
404 | Active chat not found |