Create Scope
curl --request POST \
--url https://api.truthlocks.com/v1/scopes \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"resource": "crm",
"action": "contact.enrich",
"display_name": "CRM Contact Enrichment",
"description": "Allows agents to enrich CRM contact records",
"category": "integration"
}
'import requests
url = "https://api.truthlocks.com/v1/scopes"
payload = {
"resource": "crm",
"action": "contact.enrich",
"display_name": "CRM Contact Enrichment",
"description": "Allows agents to enrich CRM contact records",
"category": "integration"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
resource: 'crm',
action: 'contact.enrich',
display_name: 'CRM Contact Enrichment',
description: 'Allows agents to enrich CRM contact records',
category: 'integration'
})
};
fetch('https://api.truthlocks.com/v1/scopes', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.truthlocks.com/v1/scopes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'resource' => 'crm',
'action' => 'contact.enrich',
'display_name' => 'CRM Contact Enrichment',
'description' => 'Allows agents to enrich CRM contact records',
'category' => 'integration'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.truthlocks.com/v1/scopes"
payload := strings.NewReader("{\n \"resource\": \"crm\",\n \"action\": \"contact.enrich\",\n \"display_name\": \"CRM Contact Enrichment\",\n \"description\": \"Allows agents to enrich CRM contact records\",\n \"category\": \"integration\"\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))
}HttpResponse<String> response = Unirest.post("https://api.truthlocks.com/v1/scopes")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"resource\": \"crm\",\n \"action\": \"contact.enrich\",\n \"display_name\": \"CRM Contact Enrichment\",\n \"description\": \"Allows agents to enrich CRM contact records\",\n \"category\": \"integration\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.truthlocks.com/v1/scopes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"resource\": \"crm\",\n \"action\": \"contact.enrich\",\n \"display_name\": \"CRM Contact Enrichment\",\n \"description\": \"Allows agents to enrich CRM contact records\",\n \"category\": \"integration\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"scope": "<string>",
"resource": "<string>",
"action": "<string>",
"display_name": "<string>",
"description": "<string>",
"category": "<string>",
"is_builtin": true,
"created_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
}Agent Sessions & Tools
Create Scope
Create a custom tenant-scoped permission scope for fine-grained agent access control
POST
/
v1
/
scopes
Create Scope
curl --request POST \
--url https://api.truthlocks.com/v1/scopes \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"resource": "crm",
"action": "contact.enrich",
"display_name": "CRM Contact Enrichment",
"description": "Allows agents to enrich CRM contact records",
"category": "integration"
}
'import requests
url = "https://api.truthlocks.com/v1/scopes"
payload = {
"resource": "crm",
"action": "contact.enrich",
"display_name": "CRM Contact Enrichment",
"description": "Allows agents to enrich CRM contact records",
"category": "integration"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
resource: 'crm',
action: 'contact.enrich',
display_name: 'CRM Contact Enrichment',
description: 'Allows agents to enrich CRM contact records',
category: 'integration'
})
};
fetch('https://api.truthlocks.com/v1/scopes', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.truthlocks.com/v1/scopes",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'resource' => 'crm',
'action' => 'contact.enrich',
'display_name' => 'CRM Contact Enrichment',
'description' => 'Allows agents to enrich CRM contact records',
'category' => 'integration'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.truthlocks.com/v1/scopes"
payload := strings.NewReader("{\n \"resource\": \"crm\",\n \"action\": \"contact.enrich\",\n \"display_name\": \"CRM Contact Enrichment\",\n \"description\": \"Allows agents to enrich CRM contact records\",\n \"category\": \"integration\"\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))
}HttpResponse<String> response = Unirest.post("https://api.truthlocks.com/v1/scopes")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"resource\": \"crm\",\n \"action\": \"contact.enrich\",\n \"display_name\": \"CRM Contact Enrichment\",\n \"description\": \"Allows agents to enrich CRM contact records\",\n \"category\": \"integration\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.truthlocks.com/v1/scopes")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"resource\": \"crm\",\n \"action\": \"contact.enrich\",\n \"display_name\": \"CRM Contact Enrichment\",\n \"description\": \"Allows agents to enrich CRM contact records\",\n \"category\": \"integration\"\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"scope": "<string>",
"resource": "<string>",
"action": "<string>",
"display_name": "<string>",
"description": "<string>",
"category": "<string>",
"is_builtin": true,
"created_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
}Create Scope
POST /v1/scopes
Creates a custom permission scope for the authenticated tenant. Custom scopes extend the built-in scope registry with tenant-specific permissions. The scope string is automatically composed from the resource and action fields in resource:action format.
Custom scopes are validated against the MAIP scope format rules: alphanumeric characters, dots, underscores, hyphens, and asterisks only.
Custom scopes are tenant-isolated. They do not appear in other tenants’ scope
registries. Built-in platform scopes cannot be overridden or duplicated.
Authentication
RequiresX-API-Key header or Bearer JWT token. Tenant-scoped via X-Tenant-ID.
Request Body
string
required
The resource component of the scope. Must contain only alphanumeric
characters, dots, underscores, and hyphens. Examples:
"crm", "payment",
"inventory.warehouse".string
required
The action component of the scope. Must contain only alphanumeric characters,
dots, underscores, hyphens, and asterisks. Examples:
"read", "approve",
"*".string
Human-readable name for the scope. Defaults to the composed
resource:action
string if omitted.string
Detailed description of what the scope grants access to.
string
Organizational category for the scope. Defaults to
"custom" if omitted.
Common values: "data", "model", "tool", "integration", "custom".Response
string
UUID of the newly created scope definition.
string
UUID of the owning tenant.
string
The composed scope string in
resource:action format.string
The resource component.
string
The action component.
string
Human-readable scope name.
string
Scope description.
string
Scope category.
boolean
Always
false for tenant-created scopes.string
ISO 8601 creation timestamp.
Example
curl -X POST https://api.truthlocks.com/v1/scopes \
-H "X-API-Key: tl_live_..." \
-H "Content-Type: application/json" \
-d '{
"resource": "crm",
"action": "contact.enrich",
"display_name": "CRM Contact Enrichment",
"description": "Allows agents to enrich CRM contact records via third-party providers",
"category": "integration"
}'
Assigning Custom Scopes to Agents
After creating a custom scope, assign it to agents during registration or via delegation:curl -X POST https://api.truthlocks.com/v1/agents \
-H "X-API-Key: tl_live_..." \
-H "Content-Type: application/json" \
-d '{
"agent_type": "pipeline",
"display_name": "CRM Enrichment Pipeline",
"scopes": ["crm:contact.enrich", "data:read"]
}'
Authorizations
API key for machine-to-machine authentication
Body
application/json
Resource component of the scope (e.g. "crm", "payment")
Action component of the scope (e.g. "read", "approve", "*")
Human-readable name for the scope
Detailed description of what the scope grants
Organizational category (defaults to "custom")

