---
title: ".approve()"
description: "Register the privileged policy handler for approval-gated tools."
---

> Documentation Index
> Fetch the complete documentation index at: https://xsaf.ilha.build/llms.txt
> Use this file to discover all available pages before exploring further.

# .approve()

## Signature

```ts
agent.approve(handler: HumanApprovalHandler): XsafAgent
```

## Usage

```ts
agent.approve(async (input, { tool, sessionId }) => {
  if (tool === "delete_account") {
return confirmDeletion(sessionId, input);
  }
  return true;
});
```

## Execution order

The approval handler runs after schema validation and before sandbox execution. It is privileged: unlike public event handlers, it may inspect validated tool arguments.

Return `true` to allow execution and `false` to deny it. Approval-gated tools fail closed when no handler is registered. Untrusted MCP tools require approval by default.

Register only one approval handler. See [Tools & Security](/recipes/tools) for denial errors, argument secrecy, and approval ordering.

Source: https://xsaf.ilha.build/xsaf/approve/index.mdx
