Sitzung erstellen
curl --request POST \
--url https://api.truthlocks.com/v1/agent-sessions \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({agent_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'})
};
fetch('https://api.truthlocks.com/v1/agent-sessions', 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"
payload = { "agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a" }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(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"
payload := strings.NewReader("{\n \"agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
req, _ := http.NewRequest("POST", 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
}Agentensitzungen & Tools
Sitzung erstellen
Erstellen Sie eine zeitlich begrenzte authentifizierte Sitzung für einen Maschinenagenten mit bereichsbezogenen Zugriffstoken.
POST
/
v1
/
agent-sessions
Sitzung erstellen
curl --request POST \
--url https://api.truthlocks.com/v1/agent-sessions \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
'const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({agent_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a'})
};
fetch('https://api.truthlocks.com/v1/agent-sessions', 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"
payload = { "agent_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a" }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(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"
payload := strings.NewReader("{\n \"agent_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n}")
req, _ := http.NewRequest("POST", 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
}Sitzung erstellen
POST /v1/agent-sessions
Erstellt eine neue authentifizierte Sitzung für einen Maschinenagenten. Die Sitzung bindet ein zeitlich begrenztes Zugriffstoken und ein Aktualisierungstoken an den Agenten, mit einem expliziten Satz von Scopes, der eine Untermenge der dem Agenten gewährten Scopes sein muss.
Die token und refresh_token werden nur in der Erstellungsantwort zurückgegeben. Speichern Sie sie sicher – sie können später nicht wiederhergestellt werden.
Die Felder
token und refresh_token werden in dieser
Antwort. Speichern Sie sie in einem sicheren Secrets Manager oder verschlüsselten Speicher
sofort. Bei Verlust die Sitzung beenden und eine neue erstellen.Authentifizierung
ErfordertX-API-Key Header oder Bearer JWT Token. Der Arbeitsbereich wird aus den authentifizierten Anmeldeinformationen abgeleitet; senden Sie X-Tenant-ID nicht.
Antwort
MAIP-Sitzungsbezeichner im Format
maip-sess:<short-uuid>:<random-hex>.
Verwenden Sie diese ID in nachfolgenden API-Aufrufen.Opaker Zugriffstoken zur Authentifizierung von API-Anfragen innerhalb dieser Sitzung.
64-stelliger Hex-String. Nur einmal zurückgegeben.
Token zum Aktualisieren der Sitzung vor Ablauf. 64-stelliger Hex-String.
Wird nur einmal zurückgegeben.
Beispiel
curl -X POST https://api.truthlocks.com/v1/agent-sessions \
-H "X-API-Key: tl_live_..." \
-H "Content-Type: application/json" \
-d '{
"agent_id": "maip:t1234567:01HYX3KPZQ7RJGBN0WFMV8SDEH",
"scopes": ["data:read", "tool:search.web"],
"ttl_minutes": 120,
"metadata": {
"purpose": "customer-inquiry-batch-2026-04-06",
"orchestrator": "support-pipeline-v2"
}
}'
Sitzungslebenszyklus
Created (active) --> Refreshed (active) --> Expired (expired)
| |
+--> Terminated (terminated) |
| |
+--> Handed Off (handed_off) --> New Session (active)
Autorisierungen
Body
application/json
Antwort
Sitzung erstellt

