Agent Permissions

MITRITY's agent permission system controls which tools each agent can access and how. While policies govern what actions are allowed or denied, agent permissions define the boundary — which tools an agent is authorized to use at all. Permissions operate as a pre-filter: if an agent does not have permission to use a tool, the action is denied before policy evaluation.

Overview

Agent permissions link three concepts:

  1. Agent — The AI agent performing actions
  2. Tool — The tool from the tool catalog being accessed
  3. Permission — The rules governing that agent's access to that tool

Each permission specifies:

  • Mode: Allow or deny access to the tool
  • Operations: Which operations are permitted (read, write, delete, etc.)
  • Rate limits: Maximum actions per time window
  • Payload limits: Maximum request size in bytes
  • Time windows: When the permission is active
  • Scopes: Fine-grained resource access within the tool

Permission Modes

Allow Mode

The agent is permitted to use the tool, subject to the configured operations, rate limits, and constraints.

{
  "agent_id": "agt_sales-bot",
  "tool_id": "tool_crm_8k2m",
  "mode": "allow",
  "operations": ["read", "list"]
}

Deny Mode

The agent is explicitly denied access to the tool. Deny permissions take precedence over allow permissions.

{
  "agent_id": "agt_sales-bot",
  "tool_id": "tool_shell_builtin",
  "mode": "deny"
}

Default Behavior

If no permission exists for an agent-tool pair, the default behavior depends on your tenant configuration:

Default ModeBehavior
default_deny (recommended)Tools without explicit permissions are denied. Agents can only use tools explicitly granted.
default_allowTools without explicit permissions are allowed. Only explicitly denied tools are blocked.

Configure the default mode in Settings > Security > Default Permission Mode.

Operations

Operations define what the agent can do with the tool. Available operations depend on the tool definition in the catalog.

OperationDescription
readRetrieve data (SELECT, GET, download)
writeCreate or update data (INSERT, UPDATE, PUT, POST, upload)
deleteRemove data (DELETE, DROP, remove)
listEnumerate resources (list tables, list buckets, directory listing)
executeRun code or invoke functions (stored procedures, lambdas, code execution)
sendSend messages or notifications (email, chat, SMS)

Operation Filtering

Grant only the operations the agent needs:

{
  "agent_id": "agt_analytics-bot",
  "tool_id": "tool_postgres_builtin",
  "mode": "allow",
  "operations": ["read", "list"]
}

This grants the analytics bot read-only access to PostgreSQL. Any write, delete, or execute operations will be denied.

Rate Limits

Rate limits restrict how frequently an agent can use a tool. This prevents runaway agents from overwhelming resources and provides a safety net against infinite loops.

{
  "agent_id": "agt_sales-bot",
  "tool_id": "tool_crm_8k2m",
  "mode": "allow",
  "operations": ["read", "write", "list"],
  "rate_limit": {
    "max_per_minute": 60,
    "burst": 10
  }
}

Rate Limit Fields

FieldTypeDescription
max_per_minuteintegerMaximum number of actions per minute. Range: 1-10000.
burstintegerMaximum number of concurrent actions. When exceeded, new actions are queued or denied. Range: 1-1000.

When the rate limit is exceeded, the gateway returns a 429 Too Many Requests error to the agent with a Retry-After header.

Rate Limit Recommendations

Tool CategoryRecommended RateBurst
Database100-500/min20
LLM30-60/min5
Email/SMS10-30/min3
Code execution10-20/min2
Storage100-300/min20
HTTP outbound60-200/min10

Payload Limits

Payload limits restrict the size of data an agent can send in a single request. This prevents agents from exfiltrating large datasets or overwhelming downstream services.

{
  "agent_id": "agt_data-bot",
  "tool_id": "tool_s3_builtin",
  "mode": "allow",
  "operations": ["read", "write"],
  "max_payload_bytes": 10485760
}
FieldTypeDescription
max_payload_bytesintegerMaximum request body size in bytes. Default: no limit.

Common sizes:

SizeBytesUse Case
1 KB1024Simple API calls, JSON payloads
1 MB1048576Standard file uploads, data exports
10 MB10485760Large file operations
100 MB104857600Bulk data transfers

Time Windows

Time windows restrict tool access to specific hours. Actions outside the time window are denied.

{
  "agent_id": "agt_batch-processor",
  "tool_id": "tool_postgres_builtin",
  "mode": "allow",
  "operations": ["read", "write", "execute"],
  "time_window": {
    "days": ["monday", "tuesday", "wednesday", "thursday", "friday"],
    "start": "02:00",
    "end": "06:00",
    "timezone": "Europe/Stockholm"
  }
}

Time Window Fields

FieldTypeDescription
daysarrayDays of the week the window is active. Values: monday through sunday.
startstringStart time in 24-hour format (HH:MM).
endstringEnd time in 24-hour format (HH:MM).
timezonestringIANA timezone (e.g., Europe/Stockholm, America/New_York, UTC).

Spanning Midnight

To create a window that spans midnight (e.g., 22:00 to 06:00), set the end time before the start time:

{
  "time_window": {
    "days": ["monday", "tuesday", "wednesday", "thursday", "friday"],
    "start": "22:00",
    "end": "06:00",
    "timezone": "Europe/Stockholm"
  }
}

Scopes

Scopes provide fine-grained resource access within a tool. Instead of granting access to all resources within a tool, scopes limit access to specific tables, buckets, paths, or endpoints.

{
  "agent_id": "agt_analytics-bot",
  "tool_id": "tool_postgres_builtin",
  "mode": "allow",
  "operations": ["read"],
  "scopes": [
    {
      "resource_pattern": "public.analytics_*",
      "description": "Read-only access to analytics tables"
    },
    {
      "resource_pattern": "public.reports_*",
      "description": "Read-only access to reports tables"
    }
  ]
}

Scope Fields

FieldTypeDescription
resource_patternstringGlob pattern matching resources within the tool.
descriptionstringHuman-readable description of what this scope grants.

Scope Pattern Examples

ToolScope PatternMatches
PostgreSQLpublic.usersOnly the users table in the public schema
PostgreSQLpublic.analytics_*All tables starting with analytics_
S3my-bucket/reports/*Objects in the reports/ prefix
S3my-bucket/exports/*.csvOnly CSV files in the exports/ prefix
GitHuborg/repo-*Repositories matching repo-* in the org
HTTPhttps://api.internal.com/v1/*Only v1 API endpoints

Managing Permissions

List Agent Permissions

curl https://api.mitrity.com/api/v1/agents/agt_sales-bot/permissions \
  -H "Authorization: Bearer mk_live_your-api-key"

Response:

{
  "data": [
    {
      "id": "perm_8k2m4n",
      "agent_id": "agt_sales-bot",
      "tool_id": "tool_crm_8k2m",
      "tool_name": "internal-crm-api",
      "mode": "allow",
      "operations": ["read", "list"],
      "rate_limit": {
        "max_per_minute": 60,
        "burst": 10
      },
      "max_payload_bytes": null,
      "time_window": null,
      "scopes": [],
      "created_at": "2026-03-01T10:00:00Z",
      "updated_at": "2026-03-01T10:00:00Z"
    },
    {
      "id": "perm_9j3n5p",
      "agent_id": "agt_sales-bot",
      "tool_id": "tool_shell_builtin",
      "tool_name": "shell",
      "mode": "deny",
      "operations": [],
      "rate_limit": null,
      "max_payload_bytes": null,
      "time_window": null,
      "scopes": [],
      "created_at": "2026-03-01T10:00:00Z",
      "updated_at": "2026-03-01T10:00:00Z"
    }
  ],
  "meta": {
    "request_id": "req_perm001",
    "timestamp": "2026-03-01T10:05:00Z",
    "next_cursor": null,
    "total": 2
  }
}

Set a Permission

curl -X PUT https://api.mitrity.com/api/v1/agents/agt_sales-bot/permissions \
  -H "Authorization: Bearer mk_live_your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "tool_id": "tool_crm_8k2m",
    "mode": "allow",
    "operations": ["read", "write", "list"],
    "rate_limit": {
      "max_per_minute": 120,
      "burst": 20
    },
    "max_payload_bytes": 1048576,
    "scopes": [
      {
        "resource_pattern": "contacts/*",
        "description": "Access to contact resources"
      },
      {
        "resource_pattern": "deals/*",
        "description": "Access to deal resources"
      }
    ]
  }'

Response:

{
  "data": {
    "id": "perm_8k2m4n",
    "agent_id": "agt_sales-bot",
    "tool_id": "tool_crm_8k2m",
    "tool_name": "internal-crm-api",
    "mode": "allow",
    "operations": ["read", "write", "list"],
    "rate_limit": {
      "max_per_minute": 120,
      "burst": 20
    },
    "max_payload_bytes": 1048576,
    "time_window": null,
    "scopes": [
      {
        "resource_pattern": "contacts/*",
        "description": "Access to contact resources"
      },
      {
        "resource_pattern": "deals/*",
        "description": "Access to deal resources"
      }
    ],
    "created_at": "2026-03-01T10:00:00Z",
    "updated_at": "2026-03-01T12:00:00Z"
  },
  "meta": {
    "request_id": "req_perm002",
    "timestamp": "2026-03-01T12:00:00Z"
  }
}

Bulk Set Permissions

Set multiple permissions for an agent in a single request:

curl -X PUT https://api.mitrity.com/api/v1/agents/agt_sales-bot/permissions/bulk \
  -H "Authorization: Bearer mk_live_your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "permissions": [
      {
        "tool_id": "tool_crm_8k2m",
        "mode": "allow",
        "operations": ["read", "list"]
      },
      {
        "tool_id": "tool_sendgrid_builtin",
        "mode": "allow",
        "operations": ["send"],
        "rate_limit": { "max_per_minute": 10, "burst": 3 }
      },
      {
        "tool_id": "tool_shell_builtin",
        "mode": "deny"
      },
      {
        "tool_id": "tool_s3_builtin",
        "mode": "deny"
      }
    ]
  }'

Response:

{
  "data": {
    "created": 2,
    "updated": 2,
    "total": 4
  },
  "meta": {
    "request_id": "req_perm003",
    "timestamp": "2026-03-01T12:05:00Z"
  }
}

Delete a Permission

Remove a specific permission, reverting to the default behavior:

curl -X DELETE https://api.mitrity.com/api/v1/agents/agt_sales-bot/permissions/perm_8k2m4n \
  -H "Authorization: Bearer mk_live_your-api-key"

Permission Evaluation Order

When the gateway evaluates an agent action, permissions are checked in this order:

  1. Explicit deny: If a deny permission exists for the agent-tool pair, the action is denied immediately.
  2. Explicit allow: If an allow permission exists, check operations, rate limits, payload limits, time window, and scopes. If all checks pass, the action proceeds to policy evaluation.
  3. Default mode: If no permission exists, apply the tenant default mode (deny or allow).
  4. Policy evaluation: If the action passes the permission check, it proceeds to policy evaluation.
Agent Action
    │
    ▼
Explicit Deny? ──Yes──► DENIED
    │ No
    ▼
Explicit Allow? ──Yes──► Check constraints ──Pass──► Policy evaluation
    │ No                      │ Fail
    ▼                         ▼
Default Mode                DENIED
    │
    ├── default_deny ──► DENIED
    └── default_allow ──► Policy evaluation

Dashboard Management

Viewing Permissions

Navigate to Agents > [Agent Name] > Permissions to see all tool permissions for an agent. The permissions view shows:

  • All explicitly granted and denied tools
  • Active rate limit status (current usage vs limit)
  • Time window status (active or inactive)
  • Scope details

Editing Permissions

Click on any permission to modify it. Changes take effect immediately — the gateway receives updated permissions within seconds via the heartbeat channel.

Permission Templates

Create permission templates for common agent roles:

  • Read-Only Agent: Allow read and list on specified tools, deny everything else
  • Data Processing Agent: Allow read/write on databases, deny code execution and network
  • Customer Support Agent: Allow CRM read, email send, deny bulk operations

Templates are available at Tools > Permission Templates.

Best Practices

Use Default Deny

Configure your tenant with default_deny mode. This ensures agents can only access tools explicitly granted to them, following the principle of least privilege.

Start with Read-Only

When onboarding a new agent, start with read-only permissions and expand as needed. This lets you observe the agent's behavior before granting write access.

Set Rate Limits on All Tools

Even for trusted agents, set rate limits as a safety net. An agent stuck in a loop can generate thousands of requests per minute without rate limits.

Use Scopes for Sensitive Data

Instead of granting broad database access, use scopes to limit access to specific tables. An analytics agent should not need access to the users or credentials tables.

Review Permissions Regularly

Set a quarterly review cadence for agent permissions. Remove permissions for tools that are no longer used and tighten scopes based on actual usage patterns.

Document Time Windows

When using time windows, document the rationale. A future team member seeing a 02:00-06:00 window needs to understand it is for batch processing, not an arbitrary restriction.

Related Documentation

Agent Permissions — Documentation | MITRITY