Skip to main content
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"
}
'
{
  "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"
}

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

Requires X-API-Key header or Bearer JWT token. Tenant-scoped via X-Tenant-ID.

Request Body

resource
string
required
The resource component of the scope. Must contain only alphanumeric characters, dots, underscores, and hyphens. Examples: "crm", "payment", "inventory.warehouse".
action
string
required
The action component of the scope. Must contain only alphanumeric characters, dots, underscores, hyphens, and asterisks. Examples: "read", "approve", "*".
display_name
string
Human-readable name for the scope. Defaults to the composed resource:action string if omitted.
description
string
Detailed description of what the scope grants access to.
category
string
Organizational category for the scope. Defaults to "custom" if omitted. Common values: "data", "model", "tool", "integration", "custom".

Response

id
string
UUID of the newly created scope definition.
tenant_id
string
UUID of the owning tenant.
scope
string
The composed scope string in resource:action format.
resource
string
The resource component.
action
string
The action component.
display_name
string
Human-readable scope name.
description
string
Scope description.
category
string
Scope category.
is_builtin
boolean
Always false for tenant-created scopes.
created_at
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

X-API-Key
string
header
required

API key for machine-to-machine authentication

Body

application/json
resource
string
required

Resource component of the scope (e.g. "crm", "payment")

action
string
required

Action component of the scope (e.g. "read", "approve", "*")

display_name
string

Human-readable name for the scope

description
string

Detailed description of what the scope grants

category
string

Organizational category (defaults to "custom")

Response

Scope created

id
string<uuid>
tenant_id
string<uuid>
scope
string
resource
string
action
string
display_name
string
description
string
category
string
is_builtin
boolean
created_at
string<date-time>