# Execute a tool within a tool router session

**Documentation:** /reference/api-reference/tool-router/postToolRouterSessionBySessionIdExecute

Executes a specific tool within a tool router session. The toolkit is automatically inferred from the tool slug. The tool must belong to an allowed toolkit and must not be disabled in the session configuration. This endpoint validates permissions, resolves connected accounts, and executes the tool with the session context.

---

## POST `/api/v3/tool_router/session/{session_id}/execute`

**Endpoint:** `https://backend.composio.dev/api/v3/tool_router/session/{session_id}/execute`

**Summary:** Execute a tool within a tool router session

Executes a specific tool within a tool router session. The toolkit is automatically inferred from the tool slug. The tool must belong to an allowed toolkit and must not be disabled in the session configuration. This endpoint validates permissions, resolves connected accounts, and executes the tool with the session context.

### Authentication

**ApiKeyAuth** - API Key in `header` header `x-api-key` OR **UserApiKeyAuth** - API Key in `header` header `x-user-api-key`

### Path Parameters

- `session_id` (string (toolRouterSessionId)) *(required)*: Tool router session ID (required for public API, optional for internal - injected by middleware)

### Request Body

**Schema:**

- `tool_slug` (string) *(required)*: The unique slug identifier of the tool to execute
- `arguments` (object): The arguments required by the tool
  - `[key: string]` (any)

**Example:**

```json
{
  "tool_slug": "string",
  "arguments": {}
}
```

### Responses

#### 200 - Successfully executed the tool. Returns execution result, logs, and status.

**Response Schema:**

- `data` (object) *(required)*: The data returned by the tool execution
  - `[key: string]` (any)
- `error` (string,null) *(required)*: Error message if the execution failed, null otherwise
- `log_id` (string) *(required)*: Unique identifier for the execution log

**Example Response:**

```json
{
  "data": {
    "key": null
  },
  "error": null,
  "log_id": "string"
}
```

#### 400 - Bad request

**Response Schema:**

- `error` (object) *(required)*
  - `message` (string) *(required)*
  - `code` (number) *(required)*
  - `slug` (string) *(required)*
  - `status` (number) *(required)*
  - `request_id` (string)
  - `suggested_fix` (string)
  - `errors` (array<string>)

#### 401 - Unauthorized

**Response Schema:**

- `error` (object) *(required)*
  - `message` (string) *(required)*
  - `code` (number) *(required)*
  - `slug` (string) *(required)*
  - `status` (number) *(required)*
  - `request_id` (string)
  - `suggested_fix` (string)
  - `errors` (array<string>)

#### 403 - Forbidden

**Response Schema:**

- `error` (object) *(required)*
  - `message` (string) *(required)*
  - `code` (number) *(required)*
  - `slug` (string) *(required)*
  - `status` (number) *(required)*
  - `request_id` (string)
  - `suggested_fix` (string)
  - `errors` (array<string>)

#### 404 - Not found

**Response Schema:**

- `error` (object) *(required)*
  - `message` (string) *(required)*
  - `code` (number) *(required)*
  - `slug` (string) *(required)*
  - `status` (number) *(required)*
  - `request_id` (string)
  - `suggested_fix` (string)
  - `errors` (array<string>)

#### 500 - Internal server error

**Response Schema:**

- `error` (object) *(required)*
  - `message` (string) *(required)*
  - `code` (number) *(required)*
  - `slug` (string) *(required)*
  - `status` (number) *(required)*
  - `request_id` (string)
  - `suggested_fix` (string)
  - `errors` (array<string>)

### Example cURL Request

```bash
curl -X POST "https://backend.composio.dev/api/v3/tool_router/session/string/execute" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "tool_slug": "string",
    "arguments": {}
  }'
```