Create chat message
Create a new message for a specific chat.
curl --request POST \
--url https://api.useinvent.com/chats/{chat_id}/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"message": [
{
"type": "text",
"text": "<string>",
"start_ms": 1,
"end_ms": 1,
"html": true,
"json": true,
"start_timestamp": 123,
"end_timestamp": 123
}
],
"context": {
"page_url": "<string>",
"page_title": "<string>",
"timezone": "<string>"
}
}
'import requests
url = "https://api.useinvent.com/chats/{chat_id}/messages"
payload = {
"message": [
{
"type": "text",
"text": "<string>",
"start_ms": 1,
"end_ms": 1,
"html": True,
"json": True,
"start_timestamp": 123,
"end_timestamp": 123
}
],
"context": {
"page_url": "<string>",
"page_title": "<string>",
"timezone": "<string>"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
message: [
{
type: 'text',
text: '<string>',
start_ms: 1,
end_ms: 1,
html: true,
json: true,
start_timestamp: 123,
end_timestamp: 123
}
],
context: {page_url: '<string>', page_title: '<string>', timezone: '<string>'}
})
};
fetch('https://api.useinvent.com/chats/{chat_id}/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.useinvent.com/chats/{chat_id}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'message' => [
[
'type' => 'text',
'text' => '<string>',
'start_ms' => 1,
'end_ms' => 1,
'html' => true,
'json' => true,
'start_timestamp' => 123,
'end_timestamp' => 123
]
],
'context' => [
'page_url' => '<string>',
'page_title' => '<string>',
'timezone' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.useinvent.com/chats/{chat_id}/messages"
payload := strings.NewReader("{\n \"message\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"start_ms\": 1,\n \"end_ms\": 1,\n \"html\": true,\n \"json\": true,\n \"start_timestamp\": 123,\n \"end_timestamp\": 123\n }\n ],\n \"context\": {\n \"page_url\": \"<string>\",\n \"page_title\": \"<string>\",\n \"timezone\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.useinvent.com/chats/{chat_id}/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"message\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"start_ms\": 1,\n \"end_ms\": 1,\n \"html\": true,\n \"json\": true,\n \"start_timestamp\": 123,\n \"end_timestamp\": 123\n }\n ],\n \"context\": {\n \"page_url\": \"<string>\",\n \"page_title\": \"<string>\",\n \"timezone\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.useinvent.com/chats/{chat_id}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"message\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"start_ms\": 1,\n \"end_ms\": 1,\n \"html\": true,\n \"json\": true,\n \"start_timestamp\": 123,\n \"end_timestamp\": 123\n }\n ],\n \"context\": {\n \"page_url\": \"<string>\",\n \"page_title\": \"<string>\",\n \"timezone\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"role": "user",
"model": "<string>",
"status": "RUNNING",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"messages": [
{
"role": "system",
"parts": [
{
"type": "text",
"text": "<string>",
"audio": {
"id": "<string>",
"file_path": "<string>",
"file_filename": "document.pdf",
"file_size": 1024,
"file_mimetype": "application/pdf",
"file_url": "<string>",
"created_at": "2023-11-07T05:31:56Z"
},
"start_ms": 1,
"end_ms": 1,
"html": true,
"json": true,
"start_timestamp": 123,
"end_timestamp": 123
}
]
}
],
"member": {
"id": "<string>",
"role": "ADMIN",
"user": {
"id": "<string>",
"name": "<string>",
"avatar": "<string>"
},
"session": {
"id": "<string>"
},
"contact_channel": {
"id": "<string>",
"type": "internal",
"user_id": "<string>",
"avatar": "<string>",
"name": "<string>",
"username": "<string>",
"email": "jsmith@example.com",
"phone": "<string>",
"country": "<string>",
"agent": "<string>",
"ip": "<string>",
"language": "<string>",
"contact": {
"id": "<string>",
"name": "<string>",
"blocked": true,
"unsubscribed": true,
"ai_replies": true,
"is_admin": true,
"segments": [
{
"id": "<string>",
"name": "<string>",
"color": "red",
"contacts_count": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
]
},
"link": "<string>"
},
"agent": {
"id": "<string>",
"name": "<string>",
"icon": "<string>",
"color": "red",
"shape": "square",
"avatar_url": "<string>"
},
"seen_at": "2023-11-07T05:31:56Z"
},
"error": "<string>",
"broadcast_id": "<string>",
"is_broadcast_message": true,
"channel_type": "internal",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"total_tokens": 123,
"reasoning_tokens": 123,
"input_tokens_cache_read": 123,
"input_tokens_cache_write": 123,
"turns": [
{
"input_tokens": 123,
"output_tokens": 123,
"total_tokens": 123,
"reasoning_tokens": 123,
"input_tokens_cache_read": 123,
"input_tokens_cache_write": 123
}
]
},
"delivered_at": "2023-11-07T05:31:56Z",
"reactions": [
{
"emoji": "<string>",
"member_id": "<string>"
}
]
}Authorizations
Bearer token authentication using your API key
Path Parameters
Chat ID
Body
The user message
The user message to open the chat with
1User message parts
- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
- Option 7
Show child attributes
Show child attributes
Ephemeral context about where the user is when sending the message. Injected into the prompt on the fly, never stored.
Show child attributes
Show child attributes
Response
The chat message schema
The role of the message
user, assistant, system, tool, event, note The model used for the message
The chat status
RUNNING, COMPLETED, FAILED, CANCELED The message content
System message
- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
- Option 6
Show child attributes
Show child attributes
The member of the chat
Show child attributes
Show child attributes
Error message if the message failed
ID of the broadcast this message originates from
Whether this message was sent via a broadcast template
The channel the message arrived through, if any
internal, org, agent, custom, whatsapp_bot, messenger_bot, instagram_dm, tiktok_dm, telegram_bot, slack_bot, teams_bot, gmail, outlook, twilio, telnyx, email, smpp The usage information for the message
Show child attributes
Show child attributes
When the message was delivered to the recipient
Emoji reactions on the message
Show child attributes
Show child attributes
Was this page helpful?
curl --request POST \
--url https://api.useinvent.com/chats/{chat_id}/messages \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"message": [
{
"type": "text",
"text": "<string>",
"start_ms": 1,
"end_ms": 1,
"html": true,
"json": true,
"start_timestamp": 123,
"end_timestamp": 123
}
],
"context": {
"page_url": "<string>",
"page_title": "<string>",
"timezone": "<string>"
}
}
'import requests
url = "https://api.useinvent.com/chats/{chat_id}/messages"
payload = {
"message": [
{
"type": "text",
"text": "<string>",
"start_ms": 1,
"end_ms": 1,
"html": True,
"json": True,
"start_timestamp": 123,
"end_timestamp": 123
}
],
"context": {
"page_url": "<string>",
"page_title": "<string>",
"timezone": "<string>"
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
message: [
{
type: 'text',
text: '<string>',
start_ms: 1,
end_ms: 1,
html: true,
json: true,
start_timestamp: 123,
end_timestamp: 123
}
],
context: {page_url: '<string>', page_title: '<string>', timezone: '<string>'}
})
};
fetch('https://api.useinvent.com/chats/{chat_id}/messages', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.useinvent.com/chats/{chat_id}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'message' => [
[
'type' => 'text',
'text' => '<string>',
'start_ms' => 1,
'end_ms' => 1,
'html' => true,
'json' => true,
'start_timestamp' => 123,
'end_timestamp' => 123
]
],
'context' => [
'page_url' => '<string>',
'page_title' => '<string>',
'timezone' => '<string>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.useinvent.com/chats/{chat_id}/messages"
payload := strings.NewReader("{\n \"message\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"start_ms\": 1,\n \"end_ms\": 1,\n \"html\": true,\n \"json\": true,\n \"start_timestamp\": 123,\n \"end_timestamp\": 123\n }\n ],\n \"context\": {\n \"page_url\": \"<string>\",\n \"page_title\": \"<string>\",\n \"timezone\": \"<string>\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.useinvent.com/chats/{chat_id}/messages")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"message\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"start_ms\": 1,\n \"end_ms\": 1,\n \"html\": true,\n \"json\": true,\n \"start_timestamp\": 123,\n \"end_timestamp\": 123\n }\n ],\n \"context\": {\n \"page_url\": \"<string>\",\n \"page_title\": \"<string>\",\n \"timezone\": \"<string>\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.useinvent.com/chats/{chat_id}/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"message\": [\n {\n \"type\": \"text\",\n \"text\": \"<string>\",\n \"start_ms\": 1,\n \"end_ms\": 1,\n \"html\": true,\n \"json\": true,\n \"start_timestamp\": 123,\n \"end_timestamp\": 123\n }\n ],\n \"context\": {\n \"page_url\": \"<string>\",\n \"page_title\": \"<string>\",\n \"timezone\": \"<string>\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"role": "user",
"model": "<string>",
"status": "RUNNING",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"messages": [
{
"role": "system",
"parts": [
{
"type": "text",
"text": "<string>",
"audio": {
"id": "<string>",
"file_path": "<string>",
"file_filename": "document.pdf",
"file_size": 1024,
"file_mimetype": "application/pdf",
"file_url": "<string>",
"created_at": "2023-11-07T05:31:56Z"
},
"start_ms": 1,
"end_ms": 1,
"html": true,
"json": true,
"start_timestamp": 123,
"end_timestamp": 123
}
]
}
],
"member": {
"id": "<string>",
"role": "ADMIN",
"user": {
"id": "<string>",
"name": "<string>",
"avatar": "<string>"
},
"session": {
"id": "<string>"
},
"contact_channel": {
"id": "<string>",
"type": "internal",
"user_id": "<string>",
"avatar": "<string>",
"name": "<string>",
"username": "<string>",
"email": "jsmith@example.com",
"phone": "<string>",
"country": "<string>",
"agent": "<string>",
"ip": "<string>",
"language": "<string>",
"contact": {
"id": "<string>",
"name": "<string>",
"blocked": true,
"unsubscribed": true,
"ai_replies": true,
"is_admin": true,
"segments": [
{
"id": "<string>",
"name": "<string>",
"color": "red",
"contacts_count": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
]
},
"link": "<string>"
},
"agent": {
"id": "<string>",
"name": "<string>",
"icon": "<string>",
"color": "red",
"shape": "square",
"avatar_url": "<string>"
},
"seen_at": "2023-11-07T05:31:56Z"
},
"error": "<string>",
"broadcast_id": "<string>",
"is_broadcast_message": true,
"channel_type": "internal",
"usage": {
"input_tokens": 123,
"output_tokens": 123,
"total_tokens": 123,
"reasoning_tokens": 123,
"input_tokens_cache_read": 123,
"input_tokens_cache_write": 123,
"turns": [
{
"input_tokens": 123,
"output_tokens": 123,
"total_tokens": 123,
"reasoning_tokens": 123,
"input_tokens_cache_read": 123,
"input_tokens_cache_write": 123
}
]
},
"delivered_at": "2023-11-07T05:31:56Z",
"reactions": [
{
"emoji": "<string>",
"member_id": "<string>"
}
]
}