Skip to main content

Overview

The Tool Policy Hooks endpoint lets you enforce your organization’s tool policies on agent tool calls. Before your agent executes a tool — whether it’s a terminal command, an MCP tool, or any other action — your agent sends an inbound request to this endpoint and the gateway returns a decision. This is a request the agent makes to Unbound; Unbound does not call out to your agent. Any agent framework or custom application can integrate with it. Policies are configured at gateway.getunbound.ai/policies/tool-policies.

Endpoint

Authentication

Include your API key in the Authorization header:

Request Body

pre_tool_use_data Object

Response

Decision Values

How It Works

The endpoint handles two types of tools differently: Terminal commands (Bash, Shell, exec): The command is automatically classified and matched against your configured terminal command policies. MCP tools: The mcp_server and mcp_tool from metadata are matched against your MCP tool policies. Other tools: Tools that don’t match a terminal command or MCP tool pattern return allow.

Examples

Terminal Command (Blocked)

Response:

Terminal Command (Allowed)

Response:

MCP Tool

Response (depends on your configured policies):

Error responses

The gateway currently returns 200 OK with decision: "allow" for requests that are malformed or unauthenticated — a fail-open posture. There is no structured error envelope today.
If your client needs fail-closed behavior, gate it locally before calling the endpoint (validate the request body, confirm the API key is present) rather than relying on the gateway to reject.
Only cache policy_check_failure_action from authenticated, policy-evaluated responses — those reflect your organization’s real config. The policy_check_failure_action: "allow" returned in the error response above is a hardcoded fail-open value emitted because the gateway couldn’t evaluate the org’s policies; it does not represent the org’s configured posture. A client that caches the value from an error response (for example, right after an API-key rotation) will silently apply fail-open behavior even on a fail-closed org. Treat the last-known value from a successful authenticated response as authoritative, and refuse to update the cached value from an error-shape response.
This is the current behavior, not an aspirational contract. If you need a structured error response shape, file a request with Unbound support.

Integration Guide

To integrate tool policies into your agent framework:
  1. Before each tool execution, send a POST request to /v1/hooks/pretool with the tool details
  2. Check the decision in the response:
    • allow — execute the tool normally
    • deny — block execution and surface the reason to the user
    • ask — prompt the user for confirmation, or treat as allow if your agent has no interactive UI
  3. Handle errors gracefully — if the endpoint is unreachable, decide whether to fail open (allow) or fail closed (deny) based on your security requirements
  4. Configure policies at gateway.getunbound.ai/policies/tool-policies