# MULTI

> Start a transaction that queues commands until EXEC.

URL: https://docs.hotkv.com/commands/multi/

```
MULTI
```

- Group: Transactions
- Complexity: O(1)
- HotKV Cloud: all plans
- On-Premise: no license needed

`MULTI` starts a transaction on the connection. The commands you send after it
are not run right away: each is checked and queued, and the server replies
`QUEUED`. [EXEC](https://docs.hotkv.com/commands/exec/index.md) then runs the whole queue in order, with no
command from another client in between. [DISCARD](https://docs.hotkv.com/commands/discard/index.md) drops
the queue instead.

A command that is refused while queuing (an unknown command, the wrong number
of arguments, an ACL denial, a cluster redirect, or a command that is not
allowed in a transaction, such as `SAVE`, `SHUTDOWN`, `SYNC` or `PSYNC`)
replies with its error at once and makes the later `EXEC` fail with
`EXECABORT`. Errors a command hits while it runs inside `EXEC` do not stop the
other commands. [WATCH](https://docs.hotkv.com/commands/watch/index.md), `QUIT` and `RESET` run immediately
even inside a transaction.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| The transaction started | Simple string `OK` | Simple string `OK` |
| Already in a transaction | Error `ERR MULTI calls can not be nested` | Error |

## Examples

```
127.0.0.1:6379> MULTI
OK
127.0.0.1:6379(TX)> INCR orders
QUEUED
127.0.0.1:6379(TX)> LPUSH recent order:1001
QUEUED
127.0.0.1:6379(TX)> EXEC
1) (integer) 1
2) (integer) 1
```

## Compatibility

Same as Redis 7 and Valkey 8.

## See also

[EXEC](https://docs.hotkv.com/commands/exec/index.md), [DISCARD](https://docs.hotkv.com/commands/discard/index.md),
[WATCH](https://docs.hotkv.com/commands/watch/index.md), [UNWATCH](https://docs.hotkv.com/commands/unwatch/index.md)