> ## Documentation Index
> Fetch the complete documentation index at: https://trigger.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage tool permissions

> Build permission flows for the tools your agents use: connections, grants, and long waits for human approval.

You can use Trigger.dev's [human-in-the-loop](https://trigger.dev/docs/ai-chat/patterns/human-in-the-loop.md) features to build permission flows for the tools your agents use.

There are two main parts to this: connections and grants.

| Part | What it does | Example |
| - | - | - |
| Connections | Holds the OAuth tokens that let your agent act on the user's Gmail, Slack or GitHub | The user connected their Gmail account, so the agent can send email as them |
| Grants | Records which tools each user has allowed to run without asking, such as "always allow sending email" | The user clicked "Always allow" on sending email, so you saved a `gmail:send` grant for them |

You can manage these in your database or using tools like Composio.

Trigger.dev can help you with the long waits for human approval. Your agent might request permission to send an email but not hear back for days. Trigger.dev helps you suspend that workflow and continue it once the user approves, without being charged while it's suspended.

## How it works

Before each tool call, check whether the user has a grant that covers it. If they do, the tool runs. If not, the agent asks the user and waits for an answer.

## Where the agent waits

* **In a chat**, a `chat.agent` [tool approval](https://trigger.dev/docs/ai-chat/patterns/human-in-the-loop.md#approve-a-tool-before-execution) ends the turn with the call waiting for an answer. The run [releases compute](https://trigger.dev/docs/ai-chat/patterns/human-in-the-loop.md#duration-and-cost-while-paused) while it waits.
* **Outside a chat**, such as in a scheduled job or a background agent, a [wait token](https://trigger.dev/docs/wait-for-token.md) suspends the run. Ask the user by email, Slack or your app, and complete the token from your backend when they answer.

## Choose a guide

Both guides cover grants and approvals. They assume you already store the user's connections.

> [card] [In a chat](https://trigger.dev/docs/ai-chat/patterns/tool-permissions-chat.md)
>
> Check grants before each tool call and add approve once, always allow and deny buttons.

> [card] [Outside a chat](https://trigger.dev/docs/ai-chat/patterns/tool-permissions-outside-chat.md)
>
> Check grants in a task and wait for an answer with a wait token.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.