# LibTmux.Server.new_session/3

- **Module:** LibTmux
- **Package:** libtmux
- **Language:** Elixir
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-elixir/blob/00d34b3d387da72a5a416f1dd3962a98c76cedd2/lib/libtmux/server.ex#L443
- **Page:** https://libtmux.org/en/elixir/latest/reference/libtmux-server-new_session-3/

```
new_session(server, name, options \\ [])
@spec new_session(t(), binary(), [
        LibTmux.Action.creation_option()
      ]) ::
        {:ok,
         LibTmux.Action.result(
           LibTmux.Action.creation_value()
         )}
        | {:error, LibTmux.Action.error()}
```

Creates a named detached session on an existing server through one-shot execution.

Returns `{:ok, result}` on completion, with `%{id: session_id, ref: nil}`
as its value. Capture a fresh observation for a bound reference. There is
no observed target to validate; this command acts on the server answering
at the descriptor's endpoint. It never starts a missing server. A missing
endpoint or duplicate session name returns an error with execution evidence.
Control connections are unsupported.

Names contain 1..1024 UTF-8 bytes without control characters. Format syntax
stays literal; tmux's version-dependent name normalization still applies.
Options are `timeout` (5000ms), literal `cwd`, and `command`: `:default`,
`{:shell, nonempty_bytes}` or `{:argv, [program | arguments]}`. Command forms
follow `LibTmux.Pane.split/3`, except `:empty` is unsupported for creation.
Acknowledgement does not prove that the program started or finished.
See `LibTmux.Action` for completion and failure handling.

    alias LibTmux.Server

    Server.new_session(server, "extra-work", command: {:argv, ["/bin/cat"]})

## Parameters

- `server` (`t()`)
- `name` (`binary()`)
- `options` (`[LibTmux.Action.creation_option()]`)
  Default: `[]`.
