Terminar sesión
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
}Sesiones y Herramientas de Agente
Terminar sesión
Terminar inmediatamente una sesión de agente activa, invalidando sus tokens
DELETE
/
v1
/
agent-sessions
/
{sessionId}
Terminar sesión
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
}Terminar Sesión
DELETE /v1/agent-sessions/{sessionID}
Termina inmediatamente una sesión de agente activa. El token de acceso y el token de actualización de la sesión se invalidan, y el estado de la sesión pasa a "terminated". Cualquier llamada API posterior que utilice los tokens de esta sesión será rechazada.
La terminación de la sesión se registra en el registro de auditoría con un
evento
AGENT_SESSION_TERMINATED. Un recibo de terminación no se genera automáticamente
generado — use la API de recibos para crear uno si su flujo de trabajo de cumplimiento
lo requiere.Autenticación
Requiere el encabezadoX-API-Key o el token Bearer JWT. El espacio de trabajo se deriva de la credencial autenticada; no envíe X-Tenant-ID.
Respuesta
Ejemplo
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."
}'
Limpieza masiva de sesiones
Para terminar todas las sesiones activas de un agente específico (por ejemplo, durante la respuesta a un incidente), liste las sesiones filtradas por agente y estado, luego termine cada una:# 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
Para una respuesta más rápida a incidentes, suspender el
agente bloquea inmediatamente todas las
operaciones de sesión sin requerir la terminación individual de la sesión.
Respuesta
Sesión terminada

