Skip to main content

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

FieldTypeDescription
messagestringText content. Required if there is no file
filebinaryOptional 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 groupMessage type
image/*IMAGE
video/*VIDEO
audio/*AUDIO
otherFILE
no fileTEXT

Successful response

{
"success": true
}

The sent message appears in history. The bot/agent reply arrives via the Socket.IO message event.

Errors

StatusMeaning
400Invalid form (e.g. neither text nor file)
401Invalid or missing JWT
404Active chat not found