On this page

Agent keys

Create a key per agent with a preset, allowed and denied tables, a row limit, a timeout and the statements that need approval.

#Presets

PresetCanCannotConnections
Read-onlySELECT on the allowed tablesWrite anythingAPI, MCP, direct
App developerRead and write rows of the allowed tablesChange the schema; writes without WHERE and big changes wait for approvalAPI, MCP, direct
MigrationsChange the schema (acts with the project owner's rights)Drops, column removals, policy, privilege and extension changes run only after approvalAPI and MCP only

#Settings

SettingMeaning
Allowed tablesschema.table or schema.*, default public.*. The key's Postgres role gets grants only on these.
Denied tablesNever readable or writable, even if allowed by a pattern.
Max rows per statementA statement that changes more rows is rolled back, then refused or sent for approval.
Statement timeoutPer statement, also set on the Postgres role.
Needs approvalWhich risky statements wait for a person instead of being refused (see Approvals).
Call your own functionsOff by default. SECURITY DEFINER functions must also be listed by name.
Direct connectionA Postgres connection string for the key's role (read-only and app developer presets).
Bypass Row Level SecurityOff: only rows your policies allow (TO public or for the agent's role). On: all rows of the allowed tables.

#Manage keys with the API

Terminal
# Create (owner / admin, or an organization token with projects:write)
curl -X POST https://stitchdb.com/platform/v1/projects/<ref>/agent-keys \
  -H "Authorization: Bearer <access token>" -H "Content-Type: application/json" \
  -d '{"name": "support-bot", "preset": "app-dev",
       "policy": {"tables": {"allow": ["public.*"], "deny": ["public.payments"]}, "max_rows": 100}}'

GET    /platform/v1/projects/<ref>/agent-keys
PATCH  /platform/v1/projects/<ref>/agent-keys/<id>   {"policy": {...}, "name": "..."}
DELETE /platform/v1/projects/<ref>/agent-keys/<id>
LimitFreeProScaleEnterprise
Agent keys per project125100100