Create a new session
curl --request POST \
--url http://localhost:3000/api/messaging/sessions \
--header 'Content-Type: application/json' \
--data '
{
"agentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"userId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"metadata": {
"platform": "<string>",
"username": "<string>",
"discriminator": "<string>",
"avatar": "<string>"
},
"timeoutConfig": {
"timeoutMinutes": 722,
"autoRenew": true,
"maxDurationMinutes": 123,
"warningThresholdMinutes": 123
}
}
'import requests
url = "http://localhost:3000/api/messaging/sessions"
payload = {
"agentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"userId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"metadata": {
"platform": "<string>",
"username": "<string>",
"discriminator": "<string>",
"avatar": "<string>"
},
"timeoutConfig": {
"timeoutMinutes": 722,
"autoRenew": True,
"maxDurationMinutes": 123,
"warningThresholdMinutes": 123
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
agentId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
userId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
metadata: {
platform: '<string>',
username: '<string>',
discriminator: '<string>',
avatar: '<string>'
},
timeoutConfig: {
timeoutMinutes: 722,
autoRenew: true,
maxDurationMinutes: 123,
warningThresholdMinutes: 123
}
})
};
fetch('http://localhost:3000/api/messaging/sessions', 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",
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([
'agentId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'userId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'metadata' => [
'platform' => '<string>',
'username' => '<string>',
'discriminator' => '<string>',
'avatar' => '<string>'
],
'timeoutConfig' => [
'timeoutMinutes' => 722,
'autoRenew' => true,
'maxDurationMinutes' => 123,
'warningThresholdMinutes' => 123
]
]),
CURLOPT_HTTPHEADER => [
"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 := "http://localhost:3000/api/messaging/sessions"
payload := strings.NewReader("{\n \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"userId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"metadata\": {\n \"platform\": \"<string>\",\n \"username\": \"<string>\",\n \"discriminator\": \"<string>\",\n \"avatar\": \"<string>\"\n },\n \"timeoutConfig\": {\n \"timeoutMinutes\": 722,\n \"autoRenew\": true,\n \"maxDurationMinutes\": 123,\n \"warningThresholdMinutes\": 123\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
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("http://localhost:3000/api/messaging/sessions")
.header("Content-Type", "application/json")
.body("{\n \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"userId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"metadata\": {\n \"platform\": \"<string>\",\n \"username\": \"<string>\",\n \"discriminator\": \"<string>\",\n \"avatar\": \"<string>\"\n },\n \"timeoutConfig\": {\n \"timeoutMinutes\": 722,\n \"autoRenew\": true,\n \"maxDurationMinutes\": 123,\n \"warningThresholdMinutes\": 123\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3000/api/messaging/sessions")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"userId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"metadata\": {\n \"platform\": \"<string>\",\n \"username\": \"<string>\",\n \"discriminator\": \"<string>\",\n \"avatar\": \"<string>\"\n },\n \"timeoutConfig\": {\n \"timeoutMinutes\": 722,\n \"autoRenew\": true,\n \"maxDurationMinutes\": 123,\n \"warningThresholdMinutes\": 123\n }\n}"
response = http.request(request)
puts response.read_body{
"sessionId": "<string>",
"agentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"userId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"createdAt": "2023-11-07T05:31:56Z",
"metadata": {},
"expiresAt": "2023-11-07T05:31:56Z",
"timeoutConfig": {
"timeoutMinutes": 123,
"autoRenew": true,
"maxDurationMinutes": 123,
"warningThresholdMinutes": 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 Management
Create Session
Create a new conversation session with an agent with configurable timeout and renewal policies
POST
/
api
/
messaging
/
sessions
Create a new session
curl --request POST \
--url http://localhost:3000/api/messaging/sessions \
--header 'Content-Type: application/json' \
--data '
{
"agentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"userId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"metadata": {
"platform": "<string>",
"username": "<string>",
"discriminator": "<string>",
"avatar": "<string>"
},
"timeoutConfig": {
"timeoutMinutes": 722,
"autoRenew": true,
"maxDurationMinutes": 123,
"warningThresholdMinutes": 123
}
}
'import requests
url = "http://localhost:3000/api/messaging/sessions"
payload = {
"agentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"userId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"metadata": {
"platform": "<string>",
"username": "<string>",
"discriminator": "<string>",
"avatar": "<string>"
},
"timeoutConfig": {
"timeoutMinutes": 722,
"autoRenew": True,
"maxDurationMinutes": 123,
"warningThresholdMinutes": 123
}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
agentId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
userId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
metadata: {
platform: '<string>',
username: '<string>',
discriminator: '<string>',
avatar: '<string>'
},
timeoutConfig: {
timeoutMinutes: 722,
autoRenew: true,
maxDurationMinutes: 123,
warningThresholdMinutes: 123
}
})
};
fetch('http://localhost:3000/api/messaging/sessions', 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",
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([
'agentId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'userId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'metadata' => [
'platform' => '<string>',
'username' => '<string>',
'discriminator' => '<string>',
'avatar' => '<string>'
],
'timeoutConfig' => [
'timeoutMinutes' => 722,
'autoRenew' => true,
'maxDurationMinutes' => 123,
'warningThresholdMinutes' => 123
]
]),
CURLOPT_HTTPHEADER => [
"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 := "http://localhost:3000/api/messaging/sessions"
payload := strings.NewReader("{\n \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"userId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"metadata\": {\n \"platform\": \"<string>\",\n \"username\": \"<string>\",\n \"discriminator\": \"<string>\",\n \"avatar\": \"<string>\"\n },\n \"timeoutConfig\": {\n \"timeoutMinutes\": 722,\n \"autoRenew\": true,\n \"maxDurationMinutes\": 123,\n \"warningThresholdMinutes\": 123\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
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("http://localhost:3000/api/messaging/sessions")
.header("Content-Type", "application/json")
.body("{\n \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"userId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"metadata\": {\n \"platform\": \"<string>\",\n \"username\": \"<string>\",\n \"discriminator\": \"<string>\",\n \"avatar\": \"<string>\"\n },\n \"timeoutConfig\": {\n \"timeoutMinutes\": 722,\n \"autoRenew\": true,\n \"maxDurationMinutes\": 123,\n \"warningThresholdMinutes\": 123\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:3000/api/messaging/sessions")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"agentId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"userId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"metadata\": {\n \"platform\": \"<string>\",\n \"username\": \"<string>\",\n \"discriminator\": \"<string>\",\n \"avatar\": \"<string>\"\n },\n \"timeoutConfig\": {\n \"timeoutMinutes\": 722,\n \"autoRenew\": true,\n \"maxDurationMinutes\": 123,\n \"warningThresholdMinutes\": 123\n }\n}"
response = http.request(request)
puts response.read_body{
"sessionId": "<string>",
"agentId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"userId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"createdAt": "2023-11-07T05:31:56Z",
"metadata": {},
"expiresAt": "2023-11-07T05:31:56Z",
"timeoutConfig": {
"timeoutMinutes": 123,
"autoRenew": true,
"maxDurationMinutes": 123,
"warningThresholdMinutes": 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>"
}
}The Sessions API provides a simplified way to manage conversations without dealing with servers and channels. Sessions automatically handle timeout management, renewal, and expiration.
Request Body
UUID of the agent to create a session with
UUID of the user initiating the session
Optional metadata to attach to the session
Optional timeout configuration for the session
Show Timeout Configuration Properties
Show Timeout Configuration Properties
Inactivity timeout in minutes (5-1440). Default: 30
Whether to automatically renew on activity. Default: true
Maximum total session duration in minutes. Default: 720 (12 hours)
Minutes before expiration to trigger warning. Default: 5
Response
Unique identifier for the created session
UUID of the agent
UUID of the user
ISO timestamp of session creation
ISO timestamp when the session will expire
The active timeout configuration for this session
Any metadata attached to the session
Body
application/json
Response
Session created successfully
Was this page helpful?
⌘I

