Avaliar Política MAIP
curl --request POST \
--url https://api.truthlocks.com/v1/maip/policies/evaluate \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"agent_id": "<string>",
"scope": "<string>"
}
'const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({agent_id: '<string>', scope: '<string>'})
};
fetch('https://api.truthlocks.com/v1/maip/policies/evaluate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.truthlocks.com/v1/maip/policies/evaluate"
payload = {
"agent_id": "<string>",
"scope": "<string>"
}
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/maip/policies/evaluate"
payload := strings.NewReader("{\n \"agent_id\": \"<string>\",\n \"scope\": \"<string>\"\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))
}{
"allowed": true,
"denied_by": [
"<string>"
],
"reason": "<string>",
"requires_approval": true
}{
"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
}Políticas MAIP
Avaliar Política MAIP
Avalia todas as políticas de agente ativas em relação a um agente específico e escopo solicitado
POST
/
v1
/
maip
/
policies
/
evaluate
Avaliar Política MAIP
curl --request POST \
--url https://api.truthlocks.com/v1/maip/policies/evaluate \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"agent_id": "<string>",
"scope": "<string>"
}
'const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({agent_id: '<string>', scope: '<string>'})
};
fetch('https://api.truthlocks.com/v1/maip/policies/evaluate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.truthlocks.com/v1/maip/policies/evaluate"
payload = {
"agent_id": "<string>",
"scope": "<string>"
}
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/maip/policies/evaluate"
payload := strings.NewReader("{\n \"agent_id\": \"<string>\",\n \"scope\": \"<string>\"\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))
}{
"allowed": true,
"denied_by": [
"<string>"
],
"reason": "<string>",
"requires_approval": true
}{
"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
}Avaliar Política MAIP
POST /v1/maip/policies/evaluate
Avalia todas as políticas MAIP ativas para o inquilino autenticado contra um agente específico e escopo solicitado. Retorna se a ação é permitida, negada ou requer aprovação humana. Este é o ponto de verificação de aplicação em tempo de execução que os agentes chamam antes de realizar operações sensíveis.
A avaliação da política usa um modelo de negação-prevalece: se qualquer política ativa com um
correspondente
deny aciona a regra, a ação é bloqueada independentemente de qualquer allow
regras. O sinalizador requires_approval é aditivo — ele pode ser definido mesmo quando o
ação é permitida.Autenticação
Requer cabeçalhoX-API-Key ou token JWT de portador. Com escopo de locatário via cookie ou declaração JWT.
Lógica de Avaliação
A avaliação realiza três verificações sequenciais:- Verificação de Status do Agente — O agente deve ter
status: "active". Agentes suspensos ou revogados são sempre negados. - Verificação de Acesso ao Escopo — O escopo solicitado deve estar presente nos escopos concedidos do agente. Escopos explicitamente negados (prefixados com
!) sempre bloqueiam o acesso. - Verificação de Regras de Política — Todas as políticas de locatário ativas são avaliadas em ordem de prioridade. As condições de cada regra são combinadas com AND. Se alguma regra
denycorresponder, a ação é bloqueada.
Resposta
Razão legível por humanos para a negação. Uma das seguintes: -
"agent is not active" — Agente
está suspenso ou revogado - "scope not granted to agent" — Escopo não em
escopos concedidos do agente - "denied by policy" — Uma ou mais políticas bloquearam
a açãotrue se qualquer regra de política correspondente tiver requires_approval: true, mesmo que o
ação é permitida de outra forma. O chamador deve apresentar uma aprovação humana
fluxo de trabalho antes de prosseguir.Exemplo
curl -X POST https://api.truthlocks.com/v1/maip/policies/evaluate \
-H "X-API-Key: tl_live_..." \
-H "Content-Type: application/json" \
-d '{
"agent_id": "maip:t1234567:01HYX3KPZQ7RJGBN0WFMV8SDEH",
"scope": "data:write",
"action": "update_customer_record",
"resource": "customers/cust_12345"
}'
const response = await fetch(
"https://api.truthlocks.com/v1/maip/policies/evaluate",
{
method: "POST",
headers: {
"X-API-Key": "tl_live_...",
"Content-Type": "application/json",
},
body: JSON.stringify({
agent_id: "maip:t1234567:01HYX3KPZQ7RJGBN0WFMV8SDEH",
scope: "data:write",
action: "update_customer_record",
resource: "customers/cust_12345",
}),
},
);
const result = await response.json();
if (!result.allowed) {
console.error(`Denied by: ${result.denied_by.join(", ")}`);
} else if (result.requires_approval) {
// Route to human approval workflow
}
import requests
response = requests.post(
"https://api.truthlocks.com/v1/maip/policies/evaluate",
headers={
"X-API-Key": "tl_live_...",
"Content-Type": "application/json",
},
json={
"agent_id": "maip:t1234567:01HYX3KPZQ7RJGBN0WFMV8SDEH",
"scope": "data:write",
"action": "update_customer_record",
"resource": "customers/cust_12345",
},
)
result = response.json()
Corpo
application/json

