Terminer la 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>"
}
'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));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)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))
}{
"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
}Sessions et outils d'agent
Terminer la session
Termine immédiatement une session d’agent active, invalidant ses jetons
DELETE
/
v1
/
agent-sessions
/
{sessionId}
Terminer la 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>"
}
'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));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)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))
}{
"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
}Terminer la session
DELETE /v1/agent-sessions/{sessionID}
Termine immédiatement une session d’agent active. Le jeton d’accès et le jeton de rafraîchissement de la session sont invalidés, et le statut de la session passe à "terminated". Tout appel API ultérieur utilisant les jetons de cette session sera rejeté.
La fin de session est enregistrée dans le journal d’audit avec un
AGENT_SESSION_TERMINATED événement. Un reçu de résiliation n’est pas automatiquement
généré — utilisez l’API des reçus pour en créer un si votre flux de travail de conformité
l’exige.Authentification
Nécessite l’en-têteX-API-Key ou un jeton JWT Bearer. L’espace de travail est dérivé de l’identifiant authentifié ; n’envoyez pas X-Tenant-ID.
Réponse
Exemple
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."
}'
Nettoyage de session en masse
Pour terminer toutes les sessions actives pour un agent spécifique (par exemple, pendant la réponse à un incident), listez les sessions filtrées par agent et statut, puis terminez chacune d’elles :# 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
Pour une réponse plus rapide aux incidents, suspendre le
agent bloque immédiatement tous les
opérations de session sans nécessiter de terminaison de session individuelle.
Réponse
Session terminée

