# tmux.Server.NewSession

- **Module:** tmux.Server
- **Package:** github.com/libtmux/libtmux-go/tmux
- **Language:** Go
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-go/blob/52968a3181c1c9e6d1b26c565d4b170968ae61c0/tmux/session_lifecycle.go#L184
- **Page:** https://libtmux.org/en/go/latest/reference/tmux-server-newsession/

```
tmux.Server.NewSession(ctx: context.Context, request: NewSessionRequest) -> (Session, error)
```

NewSession creates a detached session, then returns a newly materialized [Session]. It never changes client focus. KillExisting is not rolled back; transport and context failures may be delivery-ambiguous.

The returned record has unmaterialized [Session.Windows] and [Session.Panes]
relations. Use the resolvers or [Server.Snapshot] when relations are needed.

If tmux reports an ID before a transport or refresh failure, the returned
partial Session contains its [Server] and [SessionID]. Other failures return zero.
