Terminate Session
curl --request DELETE \
--url https://api.truthlocks.com/v1/agent-sessions/{sessionId} \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"reason": "<string>"
}
'import requests
url = "https://api.truthlocks.com/v1/agent-sessions/{sessionId}"
payload = { "reason": "<string>" }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({reason: '<string>'})
};
fetch('https://api.truthlocks.com/v1/agent-sessions/{sessionId}', 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.truthlocks.com/v1/agent-sessions/{sessionId}",
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([
'reason' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.truthlocks.com/v1/agent-sessions/{sessionId}"
payload := strings.NewReader("{\n \"reason\": \"<string>\"\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.truthlocks.com/v1/agent-sessions/{sessionId}")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.truthlocks.com/v1/agent-sessions/{sessionId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"session_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"token": "<string>",
"scopes": [
"<string>"
],
"status": "active",
"metadata": {},
"expires_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"terminated_at": "2023-11-07T05:31:56Z"
}{
"code": "AUTH_REQUIRED",
"message": "Authentication required",
"http_status": 401
}{
"code": "AUTH_REQUIRED",
"message": "Authentication required",
"http_status": 401
}{
"code": "AUTH_REQUIRED",
"message": "Authentication required",
"http_status": 401
}{
"code": "AUTH_REQUIRED",
"message": "Authentication required",
"http_status": 401
}Agent Sessions & Tools
Terminate Session
Immediately terminate an active agent session, invalidating its tokens
DELETE
/
v1
/
agent-sessions
/
{sessionId}
Terminate Session
curl --request DELETE \
--url https://api.truthlocks.com/v1/agent-sessions/{sessionId} \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"reason": "<string>"
}
'import requests
url = "https://api.truthlocks.com/v1/agent-sessions/{sessionId}"
payload = { "reason": "<string>" }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.delete(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'DELETE',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({reason: '<string>'})
};
fetch('https://api.truthlocks.com/v1/agent-sessions/{sessionId}', 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.truthlocks.com/v1/agent-sessions/{sessionId}",
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([
'reason' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.truthlocks.com/v1/agent-sessions/{sessionId}"
payload := strings.NewReader("{\n \"reason\": \"<string>\"\n}")
req, _ := http.NewRequest("DELETE", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.truthlocks.com/v1/agent-sessions/{sessionId}")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.truthlocks.com/v1/agent-sessions/{sessionId}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"session_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"token": "<string>",
"scopes": [
"<string>"
],
"status": "active",
"metadata": {},
"expires_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"terminated_at": "2023-11-07T05:31:56Z"
}{
"code": "AUTH_REQUIRED",
"message": "Authentication required",
"http_status": 401
}{
"code": "AUTH_REQUIRED",
"message": "Authentication required",
"http_status": 401
}{
"code": "AUTH_REQUIRED",
"message": "Authentication required",
"http_status": 401
}{
"code": "AUTH_REQUIRED",
"message": "Authentication required",
"http_status": 401
}Terminate Session
DELETE /v1/agent-sessions/{sessionID}
Immediately terminates an active agent session. The session’s access token and refresh token are invalidated, and the session status transitions to "terminated". Any subsequent API calls using this session’s tokens will be rejected.
Session termination is recorded in the audit log with a
AGENT_SESSION_TERMINATED event. A termination receipt is not automatically
generated — use the receipts API to create one if your compliance workflow
requires it.Authentication
RequiresX-API-Key header or Bearer JWT token. Tenant-scoped via X-Tenant-ID.
Path Parameters
string
required
The MAIP session identifier (e.g.,
maip-sess:a1b2c3d4:9f8e7d6c5b4a3210).Request Body
string
Optional explanation for the termination. Recorded in the audit log. Maximum
1024 characters.
Response
string
Updated status, always
"terminated" on success.string
The MAIP session identifier that was terminated.
Example
curl -X DELETE https://api.truthlocks.com/v1/agent-sessions/maip-sess:a1b2c3d4:9f8e7d6c5b4a3210 \
-H "X-API-Key: tl_live_..." \
-H "Content-Type: application/json" \
-d '{
"reason": "Task completed. Cleaning up session resources."
}'
Bulk Session Cleanup
To terminate all active sessions for a specific agent (e.g., during incident response), list sessions filtered by agent and status, then terminate each:# 1. List active sessions for the agent
SESSIONS=$(curl -s -G https://api.truthlocks.com/v1/agent-sessions \
-H "X-API-Key: tl_live_..." \
-d "agent_id=maip:t1234567:01HYX3KPZQ7RJGBN0WFMV8SDEH" \
-d "status=active" \
| jq -r '.sessions[].session_id')
# 2. Terminate each session
for SID in $SESSIONS; do
curl -X DELETE "https://api.truthlocks.com/v1/agent-sessions/$SID" \
-H "X-API-Key: tl_live_..." \
-H "Content-Type: application/json" \
-d '{"reason": "Bulk cleanup during incident response SI-2026-0412"}'
done
For faster incident response, suspending the
agent immediately blocks all
session operations without requiring individual session termination.
Authorizations
API key for machine-to-machine authentication
Path Parameters
Session identifier
Body
application/json
Reason for termination
Response
Session terminated

