Criar Sessão
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
}Sessões e Ferramentas do Agente
Criar Sessão
Crie uma sessão autenticada com tempo limitado para um agente de máquina com tokens de acesso com escopo
POST
/
v1
/
agent-sessions
Criar Sessão
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
}Criar Sessão
POST /v1/agent-sessions
Cria uma nova sessão autenticada para um agente de máquina. A sessão vincula um token de acesso com tempo limitado e um token de atualização ao agente, com um conjunto de escopo explícito que deve ser um subconjunto dos escopos concedidos ao agente.
Os token e refresh_token são retornados apenas na resposta de criação. Armazene-os com segurança — eles não podem ser recuperados posteriormente.
Os campos
token e refresh_token são retornados apenas uma vez nesta
resposta. Armazene-os em um gerenciador de segredos seguro ou armazenamento criptografado
imediatamente. Se perdido, encerre a sessão e crie uma nova.Autenticação
Requer cabeçalhoX-API-Key ou token JWT de portador. O espaço de trabalho é derivado da credencial autenticada; não envie X-Tenant-ID.
Resposta
Identificador de sessão MAIP no formato
maip-sess:<short-uuid>:<random-hex>.
Use este ID em chamadas de API subsequentes.Token de acesso opaco para autenticar solicitações de API dentro desta sessão.
String hexadecimal de 64 caracteres. Retornada apenas uma vez.
Token para atualizar a sessão antes do vencimento. String hexadecimal de 64 caracteres.
Retornado apenas uma vez.
Exemplo
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"
}
}'
Ciclo de Vida da Sessão
Created (active) --> Refreshed (active) --> Expired (expired)
| |
+--> Terminated (terminated) |
| |
+--> Handed Off (handed_off) --> New Session (active)
Corpo
application/json
Resposta
Sessão criada

