# libtmux.Session.detach_client

- **Module:** libtmux.Session
- **Package:** libtmux
- **Language:** Python
- **Kind:** method
- **Source:** https://github.com/tmux-python/libtmux/blob/036c521c4b83ce6e434eb50afe2a0d08a6a05e46/src/libtmux/session.py#L474
- **Page:** https://libtmux.org/reference/py/libtmux-session-detach_client/

```
libtmux.Session.detach_client(self, shell_command: str | None = None) -> None
```

Detach every client attached to this session.

Maps to ``$ tmux detach-client -s <session_id>`` — the only
``detach-client`` flag group that is genuinely session-scoped.

## Parameters

- `self`
- `shell_command` (str | None) — Run a shell command on the detached client(s) after detach
(``-E`` flag).

## Example

```python
>>> with control_mode() as ctl:
...     session.detach_client()
```
