# server.Server.batch

- **Module:** server
- **Package:** libtmux
- **Language:** TypeScript
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-ts/blob/073b9d7dedad900bff6f5ec0ea47794e40225870/packages/libtmux/src/server.ts#L1712
- **Page:** https://libtmux.org/en/ts/latest/reference/server-server-batch/

```
async batch<
  const T extends readonly PlannedOperation<unknown>[],
>(
  operations: T,
  options?: CommandOptions,
): Promise<{
  -readonly [K in keyof T]: T[K] extends PlannedOperation<
    infer R
  >
    ? R
    : never;
}>
```

Run planned mutations in order, resolving each to what it made.

The batched form of calling them one at a time: the same options go in and
the same handles come out, positionally and individually typed. Calling
[`newWindow`](/en/ts/latest/reference/session-session-newwindow/) repeatedly takes one snapshot after each mutation; a batch runs
the mutations in order and resolves all of them from one final snapshot.

Not atomic, for the same reason [`Server.pipeline`](/en/ts/latest/reference/server-server-pipeline/) is not: tmux runs
them in order and stops at the first failure, leaving everything before it
applied.

## Examples

```ts
const [editor, logs] = await server.batch([
  session.plan.newWindow({ name: "editor" }),
  session.plan.newWindow({ name: "logs" }),
]);
```

## Type parameters

- `const T` (bound `readonly PlannedOperation<unknown>[]`)

## Parameters

- `operations` (`T`)
- `options?` (`CommandOptions`)

## Guides

Pages that discuss `batch`.

- [Control mode vs one-shot](/en/ts/latest/concepts/transports/)
