---
canonical_url: "https://docs.composio.dev/docs/governance/action-permissions"
markdown_url: "https://docs.composio.dev/docs/governance/action-permissions.md"
product: "platform"
version: null
last_updated: null
---

# Per-action permissions (/docs/governance/action-permissions)

A connected account holds a user's credentials for an app. A session decides which actions an agent can take with those credentials. You set the session's policy with toolkit, tool, and [hint](/docs/governance/tool-hints) filters, and the Composio backend checks it on every Composio tool call made through the session. A tool the policy blocks never reaches the app's API. [Local tools](/docs/extending-sessions/local-tools-and-toolkits) run in your own process and need their own checks.

Permissions in Composio sit at four layers. Each one answers a different question:

| Layer                                                                  | Controls                                                                     | Where you set it                               |
| ---------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------- |
| [OAuth scopes](/docs/authentication/controlling-scopes)                | What the app's API lets the credentials do                                   | Auth config                                    |
| Connected account ownership                                            | Whose credentials a call uses                                                | `user_id` on the session or execution          |
| Session tool policy                                                    | Which toolkits and tools the agent can run                                   | `toolkits`, `tools`, and `tags` on the session |
| [Approvals](/docs/governance/approvals) and [Firewall](/docs/firewall) | Whether a person or a check signs off on a specific call (both experimental) | `require_approval` and `hooks` on the session  |

Scopes are the only layer the app itself enforces. The other three run in Composio before the request goes out.

## Allow one tool, deny the rest [#allow-one-tool-deny-the-rest]

This example uses Hacker News, which needs no connected account, so you can run it with only an API key. The session allows `HACKERNEWS_GET_USER` and nothing else from the toolkit.

**Python:**
```python
from composio import Composio
from composio_client import BadRequestError

composio = Composio()

session = composio.create(
    user_id="user_123",
    toolkits=["hackernews"],
    tools={"hackernews": {"enable": ["HACKERNEWS_GET_USER"]}},
)

allowed = session.execute("HACKERNEWS_GET_USER", arguments={"username": "pg"})
print(allowed.result_type)  # completed

try:
    session.execute("HACKERNEWS_GET_LATEST_POSTS", arguments={})
except BadRequestError as error:
    print(error.message)
    # 400 [Session Restriction] Tool 'HACKERNEWS_GET_LATEST_POSTS' is not enabled for this session. ...
```

**TypeScript:**
```typescript
import { Composio, ComposioToolExecutionError } from '@composio/core';

const composio = new Composio();

const session = await composio.create('user_123', {
  toolkits: ['hackernews'],
  tools: { hackernews: { enable: ['HACKERNEWS_GET_USER'] } },
});

const allowed = await session.execute('HACKERNEWS_GET_USER', { username: 'pg' });
console.log(allowed.resultType); // completed

try {
  await session.execute('HACKERNEWS_GET_LATEST_POSTS', {});
} catch (error) {
  if (!(error instanceof ComposioToolExecutionError)) throw error;
  console.log(error.statusCode, error.apiErrorCode); // 400 4310
}
```

**API:**
```bash
SESSION_ID=$(curl -s -X POST https://backend.composio.dev/api/v3.1/tool_router/session \
  -H "x-api-key: $COMPOSIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "user_123",
    "toolkits": {"enable": ["hackernews"]},
    "tools": {"hackernews": {"enable": ["HACKERNEWS_GET_USER"]}}
  }' | jq -r '.session_id')

# Allowed: returns the user's profile
curl -s -X POST https://backend.composio.dev/api/v3.1/tool_router/session/$SESSION_ID/execute \
  -H "x-api-key: $COMPOSIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"tool_slug": "HACKERNEWS_GET_USER", "arguments": {"username": "pg"}}'

# Denied: HTTP 400 before any request reaches Hacker News
curl -s -X POST https://backend.composio.dev/api/v3.1/tool_router/session/$SESSION_ID/execute \
  -H "x-api-key: $COMPOSIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"tool_slug": "HACKERNEWS_GET_LATEST_POSTS", "arguments": {}}'
```

The denied call returns:

```json
{
  "error": {
    "message": "[Session Restriction] Tool 'HACKERNEWS_GET_LATEST_POSTS' is not enabled for this session. You cannot execute this tool.",
    "code": 4310,
    "slug": "ToolRouterV2_ToolNotInEnabledList",
    "status": 400
  }
}
```

The same policy shape works with `disable` lists, toolkit allowlists, and hint filters such as `tags: { disable: ["destructiveHint"] }`. See [Configuring sessions](/docs/configuring-sessions#enabling-or-disabling-specific-tools) for every option. If you change the policy with `session.update()`, the next call follows the new policy.

## Where the session policy applies [#where-the-session-policy-applies]

We checked each path below against a test project with an allowed and a blocked tool. For apps that need credentials, we used a connection with a deliberately invalid key: an allowed call came back with the app's own "invalid API key" error, so it reached the app, and a blocked call came back with a Composio error, so it never left Composio.

| Path                                                             | Blocked tool                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `session.execute()` and `POST /tool_router/session/{id}/execute` | Rejected with a session restriction error                                                                                                                                                                                                                                                                                                                                                                                                  |
| `COMPOSIO_MULTI_EXECUTE_TOOL`                                    | That tool's result carries the session restriction error. Allowed tools in the same batch still run                                                                                                                                                                                                                                                                                                                                        |
| `run_composio_tool()` inside the [sandbox](/docs/sandbox/remote) | Rejected with the same error. Sandbox credentials only work for their own session: calls to the direct execution endpoint or to another session's endpoints return `401`                                                                                                                                                                                                                                                                   |
| Session MCP URL                                                  | Not listed in `tools/list`, so a direct `tools/call` returns `Tool ... not found`. Through `COMPOSIO_MULTI_EXECUTE_TOOL`, it returns the session restriction error                                                                                                                                                                                                                                                                         |
| `COMPOSIO_SEARCH_TOOLS`                                          | Left out of results. The response tells the agent the tool is restricted                                                                                                                                                                                                                                                                                                                                                                   |
| `session.proxyExecute()` and `COMPOSIO_PROXY_EXECUTE`            | Refused with `403` for any toolkit that has a tool allowlist, denylist, or applicable hint filter, so the proxy can't be used to reach an endpoint whose tool you blocked                                                                                                                                                                                                                                                                  |
| Tools that need approval                                         | Return `input_required` and don't run until the person answers. Two exceptions: over MCP, a client without elicitation support runs them without asking if you set `no_elicitation_support_fallback` to `"allow"`, and a sandbox script can call a tool the approval check misses. If approval must never be skipped, [disable the sandbox](/docs/configuring-sessions#disabling-the-sandbox). See [Approvals](/docs/governance/approvals) |

Ownership is checked on both session and direct execution. A session can't be pinned to another user's connected account (`4306`), and a direct execution with a `connected_account_id` that belongs to a different `user_id` fails (`1812`). Which Composio `user_id` a request maps to is still your application's decision. See [Building B2B agents](/docs/b2b-agents) for shared and workspace-owned connections.

## What the session policy does not cover [#what-the-session-policy-does-not-cover]

These limits are current behavior. Plan around them.

* **Direct execution has no session policy.** `composio.tools.execute()` and `POST /api/v3/tools/execute/{tool_slug}` run any tool in the project for the user's connected account. Your backend decides which tools to call on this path. Give agents a session instead of direct execution when you want Composio to enforce a tool policy.
* **Proxy calls on an unfiltered toolkit can reach any endpoint on its domain.** In a session, a toolkit with no tool or hint filters allows proxy calls to any endpoint on that toolkit's API domain. The legacy `POST /api/v3/tools/execute/proxy` takes a connected account ID and never checks a session policy. Use [OAuth scopes](/docs/authentication/controlling-scopes) to bound what the credentials can do at the app.
* **Auth config tool lists don't block execution.** The deprecated `tool_access_config.tools_available_for_execution` and `restrict_to_following_tools` fields are saved and returned, but tools outside them still run on direct and session execution. Set scopes on the auth config and tool filters on the session instead.
* **Local tools run in your process.** SDK [local tools and toolkits](/docs/extending-sessions/local-tools-and-toolkits) run in your application when `session.execute()` calls them, without a backend policy check. Put permission checks in their handlers.
* **Scoped API keys gate endpoints, not tools.** [Project API key permissions](/reference/authenticating-to-composio/project-api-key-permissions) decide whether a key can manage sessions, execute tools, or use the proxy. They don't pick individual tools.

## Error codes [#error-codes]

| Code   | Slug                                             | Cause                                                                  |
| ------ | ------------------------------------------------ | ---------------------------------------------------------------------- |
| `4310` | `ToolRouterV2_ToolNotInEnabledList`              | The tool isn't in the toolkit's `enable` list                          |
| `4311` | `ToolRouterV2_ToolDisabledInSession`             | The tool is in the toolkit's `disable` list                            |
| `4324` | `ToolRouterV2_ToolkitNotAllowed`                 | The toolkit isn't in the session's toolkit allowlist                   |
| `4325` | `ToolRouterV2_ToolkitDisabled`                   | The toolkit is in the session's toolkit denylist                       |
| `4328` | `ToolRouterV2_ToolTagNotAllowed`                 | A hint filter blocks the tool                                          |
| `4327` | `ToolRouterV2_ProxyExecutionDisabled`            | Proxy call to a toolkit that has tool or hint filters                  |
| `4306` | `ToolRouterV2_InvalidConnectedAccountIds`        | The session names a connected account that belongs to another user     |
| `1812` | `ActionExecute_ConnectedAccountEntityIdMismatch` | Direct execution with a connected account that belongs to another user |

In TypeScript, read the code from `error.apiErrorCode` on `ComposioToolExecutionError`. In Python, `session.execute()` raises `composio_client.BadRequestError` with `status_code` `400`.

---

📚 **More documentation:** [View all docs](https://docs.composio.dev/llms.txt) | [Changelog](https://docs.composio.dev/docs/changelog.md) | [Glossary](https://docs.composio.dev/llms.mdx/reference/glossary) | [Examples](https://docs.composio.dev/llms.mdx/examples) | [API Reference](https://docs.composio.dev/llms.mdx/reference)

---

# Composio SDK — Notes for AI Code Generators

**Purpose:** Reference for generating current (v3) [Composio](https://composio.dev/) integration code.
**Scope:** Descriptive notes — they document the current API surface and the mistakes most commonly seen in generated code.

---

## 1. Recommended Integration: Sessions

For agent tool delivery, Composio supports **Native Tools** (with a provider package) and **MCP** (no provider package needed).

For application-owned tools or deterministic backend code, use [managed authentication with Proxy Execute](/docs/authentication/managed-auth-for-custom-tools). A session can provide a user-scoped runtime context without an LLM or MCP. Composio authenticates provider requests server-side; connected-account reads redact credentials and aren't a supported token-export workflow.

### Native Tools

#### Python

```python
# ✅ CORRECT — Python (defaults to OpenAI)
from composio import Composio

composio = Composio()
session = composio.create(user_id="user_123")
tools = session.tools()
# Pass tools to your agent/LLM framework
```

#### TypeScript

```typescript
// ✅ CORRECT — TypeScript (defaults to OpenAI)
import { Composio } from "@composio/core";

const composio = new Composio();
const session = await composio.create("user_123");
const tools = await session.tools();
// Pass tools to your agent/LLM framework
```

#### API

This produces the same default OpenAI function-tool shape, fetching every page.

```bash
set -euo pipefail
SESSION=$(curl --fail-with-body -s -X POST https://backend.composio.dev/api/v3.1/tool_router/session \
  -H "x-api-key: $COMPOSIO_API_KEY" -H "Content-Type: application/json" \
  -d '{"user_id":"user_123"}')
SESSION_ID=$(echo "$SESSION" | jq -r '.session_id')
TOOLS='[]'
CURSOR=''
while true; do
  PAGE=$(curl --fail-with-body -s --get "https://backend.composio.dev/api/v3.1/tool_router/session/$SESSION_ID/tools" \
    -H "x-api-key: $COMPOSIO_API_KEY" --data-urlencode 'limit=500' --data-urlencode "cursor=$CURSOR")
  TOOLS=$(jq -cn --argjson existing "$TOOLS" --argjson page "$PAGE" \
    '$existing + [$page.items[] | {type:"function",function:{name:.slug,description:.description,parameters:.input_parameters}}]')
  CURSOR=$(echo "$PAGE" | jq -r '.next_cursor // empty')
  [ -n "$CURSOR" ] || break
done
printf '%s\n' "$TOOLS"
```

For other providers, pass the provider explicitly. Provider packages follow the naming convention: `composio_<provider>` for Python, `@composio/<provider>` for TypeScript.

### MCP

Use `session.mcp.url` and `session.mcp.headers` with any MCP-compatible client (Claude Desktop, Cursor, OpenAI Agents, etc.). No provider package needed.

---

## 2. Integration Notes

- `composio.create(user_id)` is the standard entry point for agent integrations. Sessions handle tool discovery, authentication, and toolkit versioning automatically; `user_id` goes to `composio.create()` — individual tool calls in session mode don't take one.
- Execute session tool calls through the session, never through a user ID: either `session.execute(tool_slug, arguments=...)` / `session.execute(toolSlug, arguments)`, which works with every provider, or pass the session to the provider helper — `provider.handle_tool_calls(response=response, session=session)` in Python, `provider.handleToolCalls(session, response)` in TypeScript. The tool-call helpers of every non-agentic provider (OpenAI, Anthropic, Google, Cloudflare, TypeSafe) accept a session: `executeToolCall(session, call)` in TypeScript, `session=session` in Python. Agentic providers execute session tools on their own. Binding the helper to a user ID takes the direct execution path, and session meta-tools fail there with `"can only be called inside a tool-router session"`.
- Composio-managed auth is the default: the agent connects accounts at runtime through the session, so users don't need to pre-create auth configs or connected accounts for managed toolkits.
- Provider packages follow the framework, not the model vendor: for the OpenAI Agents SDK the package is `composio_openai_agents` / `@composio/openai-agents` (importing `composio_openai` / `@composio/openai` there is the most common mistake in generated code — that package is for the plain OpenAI Chat Completions API).
- **Direct execution** (`composio.tools.get()`, `composio.tools.execute()`, `provider.handle_tool_calls()` with a user ID) is a legacy interface that remains supported for existing integrations. Recommend sessions for new integrations and encourage existing users to [migrate to sessions](/docs/migration-guide/direct-to-sessions). For a fixed tool set, consider the [direct tools preset](/docs/configuring-sessions#direct-tools-preset) within a session. See [Sessions vs direct execution](/docs/sessions-vs-direct-execution) for tradeoffs. Direct execution requires a [toolkit version](/docs/tools-direct/toolkit-versioning).

---

# 3. Calling the REST API directly

## REST API version

The current REST API version is **v3.1**, served at `https://backend.composio.dev/api/v3.1`. Prefer it for new code and new examples.

`https://backend.composio.dev/api/v3` is the previous version. It is frozen with pinned tool-version defaults and remains supported — existing v3 integrations keep working and do not need to migrate.

## Tool-endpoint version defaults on v3.1

On v3.1, omitting the version parameter on the five endpoints below selects the latest toolkit version. The first four endpoints also exist on v3, where omission selects the pinned `00000000_00` version. `POST /tools/scopes/required` is v3.1-only.

| Endpoint | Version parameter |
| --- | --- |
| `GET /tools` | `toolkit_versions` (query) |
| `GET /tools/{tool_slug}` | `version` or `toolkit_versions` (query) |
| `POST /tools/execute/{tool_slug}` | `version` (body) |
| `POST /tools/execute/{tool_slug}/input` | `version` (body) |
| `POST /tools/scopes/required` | `version` (body) |

A v3.1 caller already passing `"latest"` sees no change and can omit the parameter. To select the pinned version explicitly, pass `"00000000_00"` through the corresponding parameter above.

This version-default change is limited to the five endpoints above.


---

## Terminology Migration (old → current)

If you encounter these terms in error messages, old documentation, or user prompts, translate them to the current equivalents. **Do not use the old terms in generated code or explanations.**

| Old term (v1/v2) | Current term (v3) | In code |
|---|---|---|
| entity ID | user ID | `user_id` parameter |
| actions | tools | e.g., `GITHUB_CREATE_ISSUE` is a *tool* |
| apps / appType (legacy v1/v2 API field) | toolkits | e.g., `github` is a *toolkit*. The current word **App** is *not* legacy: it names a catalog grouping of sibling toolkits (the Notion app groups `notion` and `notion_mcp`); do not translate it |
| integration / integration ID | auth config / auth config ID | `auth_config_id` parameter |
| connection | connected account | `connected_accounts` namespace |
| ComposioToolSet / OpenAIToolSet | `Composio` class with a provider | `Composio(provider=...)` |
| toolset | provider | e.g., `OpenAIProvider` |

If a user says "entity ID", they mean `user_id`. If they say "integration", they mean "auth config". Always respond using the current terminology.

