End Session
curl --request DELETE \
--url https://api.pathors.com/project/{projectId}/session \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"session_id": "<string>"
}
'import requests
url = "https://api.pathors.com/project/{projectId}/session"
payload = { "session_id": "<string>" }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({session_id: '<string>'})
};
fetch('https://api.pathors.com/project/{projectId}/session', 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.pathors.com/project/{projectId}/session",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'session_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.pathors.com/project/{projectId}/session"
payload := strings.NewReader("{\n \"session_id\": \"<string>\"\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.delete("https://api.pathors.com/project/{projectId}/session")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"session_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pathors.com/project/{projectId}/session")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"session_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"sessionId": "<string>",
"message": "<string>"
}Deprecated APIs
End Session
End an existing session to cleanup resources and terminate conversation context.
DELETE
/
project
/
{projectId}
/
session
End Session
curl --request DELETE \
--url https://api.pathors.com/project/{projectId}/session \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"session_id": "<string>"
}
'import requests
url = "https://api.pathors.com/project/{projectId}/session"
payload = { "session_id": "<string>" }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({session_id: '<string>'})
};
fetch('https://api.pathors.com/project/{projectId}/session', 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.pathors.com/project/{projectId}/session",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_POSTFIELDS => json_encode([
'session_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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.pathors.com/project/{projectId}/session"
payload := strings.NewReader("{\n \"session_id\": \"<string>\"\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("Authorization", "<authorization>")
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.delete("https://api.pathors.com/project/{projectId}/session")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"session_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pathors.com/project/{projectId}/session")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"session_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"sessionId": "<string>",
"message": "<string>"
}Deprecated. This endpoint is deprecated and will be sunset on 2026-07-11. It still works until then. Migrate to the V1 path — see the migration guide for the old -> new path table.
Base URL
https://api.pathors.com
End Session
DELETE https://api.pathors.com/project/{projectId}/session
Path Parameters
string
required
The ID of your project
Request Headers
string
required
Bearer token authentication using your Project API Key (starts with
sk_). Format: Bearer {your-api-key}Request Body
string
required
The unique identifier of the session to end
Response
boolean
Indicates whether the session was successfully ended
string
The ID of the ended session
string
Confirmation message that the session has been ended
Example
Request
curl -X DELETE https://api.pathors.com/project/{projectId}/session \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"session_id": "user-123-session-456"
}'
Response
{
"success": true,
"sessionId": "user-123-session-456",
"message": "Session ended successfully"
}
Usage Notes
- Resource Cleanup: Ending sessions helps free up server resources and should be done when conversations are complete
- Session Variables: All session variables and conversation context are permanently removed when a session is ended
- Session Management: The API will attempt to end the specified session. Success is returned regardless of whether the session was active
Error Responses
| Status Code | Description |
|---|---|
| 400 | Missing or invalid session_id |
| 401 | Invalid authentication |
| 500 | Internal server error |
{
"error": "session_id is required"
}
{
"error": {
"message": "Invalid authentication"
}
}
Best Practices
- Always End Sessions: End sessions when conversations are complete to prevent resource leaks
- Error Handling: Handle errors gracefully and implement appropriate retry logic for failed requests
- Session Tracking: Keep track of active session IDs in your application to manage them properly
