# 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/5f808882015a975a65acc7f9da5b3ff0d5cbdc91/tmux/session_lifecycle.go#L184
- **Page:** https://libtmux.org/reference/go/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.
