# Upstash REST /pipeline: batch for throughput, not for atomicity
## The endpoint
POST to /pipeline with a two-dimensional JSON array. Each row is a
command plus its arguments:
curl -X POST https://YOUR_REST_URL/pipeline \
-H "your auth header \
-d '[ ["SET", "key1", "valuex"], ["SETEX", "key2", 13, "valuez"], ["INCR", "key1"] ]'
The response is a JSON array in the same order:
[ { "result": "OK" }, { "result": "OK" }, { "result": 1 } ]
A failed command does not stop the rest. It shows up as an error entry
in its position.
## When to use it
- You need more throughput: one HTTP round trip instead of many.
- Your commands are independent: no later command needs an earlier
commands result to be constructed.
## The trap: it is not atomic
Commands from other clients can interleave with your pipeline. If two
commands must run with nothing in between, use /multi-exec instead:
curl -X POST https://YOUR_REST_URL/multi-exec \
-H "your auth header \
-d '[ ["SET", "key1", "valuex"], ["INCR", "key1"] ]'
A transaction is discarded as a whole on syntax errors, unsupported
commands, oversized requests, or hitting the daily request limit. Note
that WATCH, UNWATCH, and DISCARD are not supported over REST.
## SDK shortcut
In @upstash/redis, auto-pipelining is on by default: fire independent
commands together with Promise.all and they batch automatically.