Get session messages
curl --request GET \
--url http://localhost:3000/api/messaging/sessions/{sessionId}/messagesimport requests
url = "http://localhost:3000/api/messaging/sessions/{sessionId}/messages"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('http://localhost:3000/api/messaging/sessions/{sessionId}/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_PORT => "3000",
CURLOPT_URL => "http://localhost:3000/api/messaging/sessions/{sessionId}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://localhost:3000/api/messaging/sessions/{sessionId}/messages"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("http://localhost:3000/api/messaging/sessions/{sessionId}/messages")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3000/api/messaging/sessions/{sessionId}/messages")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"messages": [
{
"id": "<string>",
"content": "<string>",
"authorId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"isAgent": true,
"createdAt": "2023-11-07T05:31:56Z",
"metadata": {}
}
],
"hasMore": true,
"cursors": {
"before": 123,
"after": 123
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": "<string>"
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": "<string>"
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": "<string>"
}
}Session Messages
Get Session Messages
Retrieve messages from a conversation session with cursor-based pagination
GET
/
api
/
messaging
/
sessions
/
{sessionId}
/
messages
Get session messages
curl --request GET \
--url http://localhost:3000/api/messaging/sessions/{sessionId}/messagesimport requests
url = "http://localhost:3000/api/messaging/sessions/{sessionId}/messages"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('http://localhost:3000/api/messaging/sessions/{sessionId}/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_PORT => "3000",
CURLOPT_URL => "http://localhost:3000/api/messaging/sessions/{sessionId}/messages",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "http://localhost:3000/api/messaging/sessions/{sessionId}/messages"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("http://localhost:3000/api/messaging/sessions/{sessionId}/messages")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3000/api/messaging/sessions/{sessionId}/messages")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"messages": [
{
"id": "<string>",
"content": "<string>",
"authorId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"isAgent": true,
"createdAt": "2023-11-07T05:31:56Z",
"metadata": {}
}
],
"hasMore": true,
"cursors": {
"before": 123,
"after": 123
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": "<string>"
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": "<string>"
}
}{
"success": false,
"error": {
"code": "<string>",
"message": "<string>",
"details": "<string>"
}
}Messages are returned in reverse chronological order (newest first) by default. Use the cursor values for efficient pagination through large conversation histories.
Path Parameters
string
required
The unique identifier of the session
Query Parameters
number
Number of messages to retrieve (1-100). Default: 50
number
Timestamp to get messages before (for older messages)
number
Timestamp to get messages after (for newer messages)
Response
array
boolean
Whether more messages are available
object
Example Usage
// Get the most recent 20 messages
const response = await fetch(
'/api/messaging/sessions/abc-123/messages?limit=20'
);
const { messages, hasMore, cursors } = await response.json();
// Get older messages using the 'before' cursor
const olderMessages = await fetch(
`/api/messaging/sessions/abc-123/messages?before=${cursors.before}&limit=20`
);
// Get newer messages using the 'after' cursor
const newerMessages = await fetch(
`/api/messaging/sessions/abc-123/messages?after=${cursors.after}&limit=20`
);
// Get messages between two timestamps
const rangeMessages = await fetch(
`/api/messaging/sessions/abc-123/messages?after=1704614400000&before=1704618000000`
);
Path Parameters
ID of the session
Query Parameters
Maximum number of messages to return
Required range:
1 <= x <= 100Get messages before this timestamp
Get messages after this timestamp
Was this page helpful?

