Create Session Event
curl --request POST \
--url https://platform.perso.ai/api/v1/session/{session_id}/event/create/ \
--header 'Content-Type: application/json' \
--data '
{
"event": "SESSION_START"
}
'import requests
url = "https://platform.perso.ai/api/v1/session/{session_id}/event/create/"
payload = { "event": "SESSION_START" }
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({event: 'SESSION_START'})
};
fetch('https://platform.perso.ai/api/v1/session/{session_id}/event/create/', 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://platform.perso.ai/api/v1/session/{session_id}/event/create/",
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([
'event' => 'SESSION_START'
]),
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 := "https://platform.perso.ai/api/v1/session/{session_id}/event/create/"
payload := strings.NewReader("{\n \"event\": \"SESSION_START\"\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("https://platform.perso.ai/api/v1/session/{session_id}/event/create/")
.header("Content-Type", "application/json")
.body("{\n \"event\": \"SESSION_START\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://platform.perso.ai/api/v1/session/{session_id}/event/create/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"event\": \"SESSION_START\"\n}"
response = http.request(request)
puts response.read_body{
"sessionevent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"terminate": true,
"terminate_reason": "SESSION_EVENT_GRACEFUL_TERMINATION",
"event": "SESSION_START",
"detail": "<string>",
"file": "<string>"
}Session Lifecycle
Create Session Event
Record a session lifecycle event.
Event Types
| Event | Description | When to Use |
|---|---|---|
SESSION_START | Session has started | After WebRTC connection is established |
SESSION_DURING | Session heartbeat | Periodically during active session |
SESSION_END | Session ended normally | When user ends the session |
SESSION_ERROR | Session ended with error | When an error occurs |
SESSION_LOG | Custom log entry | For debugging/analytics |
Example
Select “CreateSessionEventRequest” from the Examples dropdown to see the request format.
POST
/
api
/
v1
/
session
/
{session_id}
/
event
/
create
/
Create Session Event
curl --request POST \
--url https://platform.perso.ai/api/v1/session/{session_id}/event/create/ \
--header 'Content-Type: application/json' \
--data '
{
"event": "SESSION_START"
}
'import requests
url = "https://platform.perso.ai/api/v1/session/{session_id}/event/create/"
payload = { "event": "SESSION_START" }
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({event: 'SESSION_START'})
};
fetch('https://platform.perso.ai/api/v1/session/{session_id}/event/create/', 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://platform.perso.ai/api/v1/session/{session_id}/event/create/",
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([
'event' => 'SESSION_START'
]),
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 := "https://platform.perso.ai/api/v1/session/{session_id}/event/create/"
payload := strings.NewReader("{\n \"event\": \"SESSION_START\"\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("https://platform.perso.ai/api/v1/session/{session_id}/event/create/")
.header("Content-Type", "application/json")
.body("{\n \"event\": \"SESSION_START\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://platform.perso.ai/api/v1/session/{session_id}/event/create/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"event\": \"SESSION_START\"\n}"
response = http.request(request)
puts response.read_body{
"sessionevent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"terminate": true,
"terminate_reason": "SESSION_EVENT_GRACEFUL_TERMINATION",
"event": "SESSION_START",
"detail": "<string>",
"file": "<string>"
}Path Parameters
Body
application/jsonapplication/x-www-form-urlencodedmultipart/form-data
Event type — see SessionEventType enum (e.g. SESSION_END, SESSION_ERROR).
SESSION_START- Session StartSESSION_DURING- Session DuringSESSION_LOG- Session LogSESSION_END- Session EndSESSION_ERROR- Session ErrorSESSION_TTS- Session TTSSESSION_STT- Session STTSESSION_LLM- Session LLMSESSION_DASHBOARD- Session DashboardSESSION_WS_LOG- Session WS LogSESSION_WS_ERROR- Session WS Error
Available options:
SESSION_START, SESSION_DURING, SESSION_LOG, SESSION_END, SESSION_ERROR, SESSION_TTS, SESSION_STT, SESSION_LLM, SESSION_DASHBOARD, SESSION_WS_LOG, SESSION_WS_ERROR Optional human-readable detail describing the event.
Optional binary file attached to the event (max 10 MB).
Response
SESSION_EVENT_GRACEFUL_TERMINATION- Graceful TerminationSESSION_EVENT_SESSION_EXPIRED_BEFORE_CONNECTION- Session Expired Before ConnectionSESSION_EVENT_SESSION_LOST_AFTER_CONNECTION- Session Lost After ConnectionSESSION_EVENT_MISC_ERROR- Session Misc ErrorSESSION_EVENT_MAX_ACTIVE_SESSION_QUOTA_EXCEEDED- Max Active Session Quota ExceededSESSION_EVENT_MAX_MIN_PER_SESSION_QUOTA_EXCEEDED- Max Min Per Session Quota ExceededSESSION_EVENT_TOTAL_MIN_PER_MONTH_QUOTA_EXCEEDED- Total Min Per Month Quota ExceededSESSION_EVENT_INSUFFICIENT_CREDITS- Insufficient Credits
Available options:
SESSION_EVENT_GRACEFUL_TERMINATION, SESSION_EVENT_SESSION_EXPIRED_BEFORE_CONNECTION, SESSION_EVENT_SESSION_LOST_AFTER_CONNECTION, SESSION_EVENT_MISC_ERROR, SESSION_EVENT_MAX_ACTIVE_SESSION_QUOTA_EXCEEDED, SESSION_EVENT_MAX_MIN_PER_SESSION_QUOTA_EXCEEDED, SESSION_EVENT_TOTAL_MIN_PER_MONTH_QUOTA_EXCEEDED, SESSION_EVENT_INSUFFICIENT_CREDITS Event type — see SessionEventType enum (e.g. SESSION_END, SESSION_ERROR).
SESSION_START- Session StartSESSION_DURING- Session DuringSESSION_LOG- Session LogSESSION_END- Session EndSESSION_ERROR- Session ErrorSESSION_TTS- Session TTSSESSION_STT- Session STTSESSION_LLM- Session LLMSESSION_DASHBOARD- Session DashboardSESSION_WS_LOG- Session WS LogSESSION_WS_ERROR- Session WS Error
Available options:
SESSION_START, SESSION_DURING, SESSION_LOG, SESSION_END, SESSION_ERROR, SESSION_TTS, SESSION_STT, SESSION_LLM, SESSION_DASHBOARD, SESSION_WS_LOG, SESSION_WS_ERROR Optional human-readable detail describing the event.
Optional binary file attached to the event (max 10 MB).

