API reference
The ToolFence Gate REST API: evaluate tool calls, hold them for bound human clearance, then complete — fail-closed.
Prefer the SDK or MCP when you can. Use these routes for custom clients.
Base URL
https://app.toolfence.ai
Self-host / local: http://127.0.0.1:8000 (or your Gate host).
OpenAPI (when enabled on the server): /openapi.json · Swagger UI /docs · ReDoc /redoc
Authentication
Send a session or service key on every /v1/* request when auth is required:
| Header | When |
|---|---|
Authorization: Bearer <token> |
Operator session from login / signup |
X-API-Key: <key> |
Service / agent key from Controls → Rotate API key |
curl -s https://app.toolfence.ai/v1/auth/me \
-H "X-API-Key: $TOOLFENCE_API_KEY"
The main flow
| Step | Endpoint |
|---|---|
| Propose a tool call | POST /v1/evaluate |
| List / poll pending | GET /v1/approvals?pending_only=true · GET /v1/approvals/{id} |
| Human clears | POST /v1/approvals/{id}/decide |
| Agent finishes | POST /v1/approvals/{id}/complete (bound fingerprint) |
POST /v1/evaluate
│
├─ allow → run tool → optional /complete
├─ deny → stop
└─ require_approval → Inbox/Slack → /decide → /complete
Endpoints
Evaluate
/v1/evaluateAsk Gate whether a tool call may run. Creates a pending approval when policy requires clearance.
Body
- tool_name string required
- Tool identifier (e.g.
refund.create). - arguments object required
- Canonical args — hashed into
bound_fingerprint. - risk string
low·medium·high·critical(policy default if omitted).- tags string[]
- Routing / list matching.
- agent_id string
- Which agent is calling.
- session_id string
- Optional session correlation.
- project_id string
- Org project for metering / Inbox filter.
{
"tool_name": "refund.create",
"arguments": { "order": "NW-8812", "amount": 189 },
"risk": "high",
"tags": ["payments"],
"agent_id": "support-bot"
}
{
"policy": {
"decision": "require_approval",
"reason": "high risk"
},
"approval": {
"id": "appr_…",
"status": "pending",
"bound_fingerprint": "fp_…"
}
}
policy.decision |
Meaning |
|---|---|
allow |
Run the tool (optionally /complete after) |
deny |
Stop — do not execute |
require_approval |
Wait for Inbox / Slack; then /decide → /complete |
List approvals
/v1/approvalsInbox list. Use pending_only=true for open clearances.
Query
- pending_only boolean
- Only pending items when
true. - agent_id string
- Filter by agent.
- project_id string
- Filter by project.
curl -s "https://app.toolfence.ai/v1/approvals?pending_only=true" \
-H "X-API-Key: $TOOLFENCE_API_KEY"
Get approval
/v1/approvals/{id}Poll status and read bound_fingerprint before complete.
Decide
/v1/approvals/{id}/decideHuman (or Slack) Approve / Deny / Respond. Edit-on-approve recomputes the bind.
Body
- approved boolean required*
trueapprove ·falsedeny (*unlessrespond).- expected_fingerprint string
- Must match evaluate bind (recommended).
- edited_arguments object
- Edit-then-approve; fingerprint recomputed.
- note string
- Auditor note.
- respond boolean
- Human answers as the tool — no execute.
- response_text string
- Payload when
respond: true. - reject_reason_code string
- Optional structured deny reason.
{
"approved": true,
"note": "ok under policy",
"expected_fingerprint": "fp_…"
}
{
"approved": false,
"reject_reason_code": "policy_violation",
"note": "amount too high"
}
Complete
/v1/approvals/{id}/completeAgent reports execution after Approve. Bound check is mandatory.
Body
- expected_fingerprint string required
- Must equal
approval.bound_fingerprint. - success boolean
- Whether the tool run succeeded.
- result_summary string
- Short audit line.
{
"success": true,
"result_summary": "Refunded $189",
"expected_fingerprint": "fp_…"
}
409 fingerprint mismatch — do not treat as cleared
Mismatch → 409. Do not execute if decide was deny / timeout / respond.
Other approval actions
/v1/approvals/{id}/extendAdd timeout seconds.
/v1/approvals/{id}/assignRoute to an assignee.
/v1/approvals/batch-decideMulti-select decide.
/v1/reject-reasonsStructured deny codes.
Policy
/v1/policy/v1/policyRisk map, allow/deny lists, per-tool overrides, routing.
/v1/policy/dry-runWhat-if evaluate without creating an approval.
MCP
/v1/mcp/configCatalog / default agent / per-tool risk. Not a live upstream proxy.
/v1/mcp/tools/callMCP-shaped gated call — same pause / clear / continue rules.
{
"name": "send_refund",
"arguments": { "customer_id": "c1", "amount": 49.99 },
"risk": "high",
"agent_id": "mcp-gate"
}
Audit & controls
/v1/auditFilterable trail.
/v1/audit/export?format=json|csvExport.
/v1/audit/pruneRetention prune.
/v1/kill-switchBlock agent / session.
/v1/notify/channelsChannel status.
/v1/notify/configChannel credentials (admin).
/v1/notify/digestPending summary fan-out.
Auth
/v1/auth/infoAuth required? SSO?
/v1/auth/signupUser + Free workspace.
/v1/auth/loginSession token.
/v1/auth/meCurrent user + key meta.
/v1/auth/rotate-api-keyNew personal agent key.
/v1/cloud/infoHosted mode, plans, marketing URL.
Fingerprint rules
- Evaluate stores
bound_fingerprintovertool_name+ canonical args - Decide may update the bind when args are edited
- Complete must send matching
expected_fingerprint - A different call (e.g. different
amount) → different fingerprint — approvals are not reusable
See Security.
Clients
| Client | Doc |
|---|---|
| Python / TypeScript SDK | SDK |
| MCP / Claude Code | Agent setup · MCP |
| Full docs index | llms.txt |