# tmux.Session.NewWindow

- **Module:** tmux.Session
- **Package:** github.com/libtmux/libtmux-go/tmux
- **Language:** Go
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-go/blob/5f808882015a975a65acc7f9da5b3ff0d5cbdc91/tmux/window_lifecycle.go#L82
- **Page:** https://libtmux.org/reference/go/tmux-session-newwindow/

```
tmux.Session.NewWindow(ctx: context.Context, request: NewWindowRequest) -> (Window, error)
```

NewWindow creates a winlink in the receiver session. Attach selects it as that session's current window; it is not a guarantee about clients attached to other sessions. The returned [Window] is freshly materialized in the receiver's exact session context, including when its stable [WindowID] is linked elsewhere.

SelectExisting no-output recovery is available only when Index is nil. It
expands Name with tmux's version-specific rules and requires exactly one
matching window name in the receiver session. An explicit Index has no such
recovery. If tmux reports a WindowID before a transport or refresh failure,
the partial result contains that ID and the receiver SessionID with Index -1.
Other failures return zero; creation is not rolled back.
