# LibTmux.Server.createSession

- **Package:** libtmux-haskell
- **Language:** Haskell
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-haskell/blob/72edb54317bf619c6dc54bff311844f062f8984c/src/LibTmux/Server.hs#L396
- **Page:** https://libtmux.org/en/haskell/latest/reference/libtmux-server-v-createsession/

```haskell
createSession
  :: Server -> SessionOptions -> IO CreatedSession
```

Signature types: [`Server`](/en/haskell/latest/reference/libtmux-server-t-server/), [`SessionOptions`](/en/haskell/latest/reference/libtmux-creation-t-sessionoptions/), [`IO`](https://hackage.haskell.org/package/base-4.22.0.0/docs/Prelude.html#t:IO), [`CreatedSession`](/en/haskell/latest/reference/libtmux-creation-t-createdsession/).

Create a detached session through this pinned Server. Start from
 [`defaultSessionOptions`](/en/haskell/latest/reference/libtmux-creation-v-defaultsessionoptions/). The result contains actual created refs,
 not observed records; capture again before inspecting the new graph.
 After-hooks may already have renamed or destroyed these targets.

## Referenced declarations

- [`LibTmux.Creation.CreatedSession`](/en/haskell/latest/reference/libtmux-creation-t-createdsession/) (typealias)
- [`LibTmux.Server.Server`](/en/haskell/latest/reference/libtmux-server-t-server/) (data type)
- [`LibTmux.Creation.SessionOptions`](/en/haskell/latest/reference/libtmux-creation-t-sessionoptions/) (data type)

## tmux command

The tmux commands behind `createSession`.

- [`new-session`](/en/tmux/latest/manual/new-session/)

## tmux C API

The C declarations in tmux that implement these commands.

- [`cmd_new_session_entry`](/en/tmux/latest/reference/c-variable-cmd_new_session_entry/) (attribute)
- [`cmd_new_session_exec`](/en/tmux/latest/reference/c-function-cmd-new-session-c-cmd_new_session_exec/) (function)

Each path starts at a function a command runs, which is degree 1. The degree counts steps from there along the path, and each step is a call or a reference: degree 2 is reached from that function, degree 3 from the next, and so on.

### Create a session and its first pane

1. [`cmd_new_session_exec`](/en/tmux/latest/reference/c-function-cmd-new-session-c-cmd_new_session_exec/) (function)
2. calls → [`spawn_window`](/en/tmux/latest/reference/c-function-spawn_window/) (function)
3. calls → [`spawn_pane`](/en/tmux/latest/reference/c-function-spawn_pane/) (function)
4. calls → [`window_add_pane`](/en/tmux/latest/reference/c-function-window_add_pane/) (function)
5. calls → [`window_pane_create`](/en/tmux/latest/reference/c-function-window-c-window_pane_create/) (function)

## Guides

Pages that discuss `createSession`.

- [Create sessions, windows and panes](/en/haskell/latest/guides/creation/)
- [Change targets and observe pane text](/en/haskell/latest/guides/mutations/)
