Upstash Documentation

JSON.MSET

Set values in multiple keys.
2 min read

Use JSON.MSET to set values at paths in several JSON documents in one atomic call.

Each triple gives a key, a path, and a value, and missing keys are created. Either every write is applied or none is, with no other command running in between, which is what makes it the right tool for documents that must stay consistent with each other. The reply is OK.

Syntax#

Arguments#

ArgumentRequiredRepeatableDescription
key path valueYesYesOne or more key, path, and valid-JSON-value triples.

Important points#

  • Raw TCP examples pass JSON values as valid JSON text. Typed Upstash SDK helpers serialize native objects and values for you.
  • Paths beginning with $ use JSONPath and can match multiple values, so many JSON commands return an array of per-match results.

Response#

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.

ProtocolReply
RESP2Simple string OK
RESP3Simple string OK
Note

Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples#

TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.

Redis CLI
@upstash/redis
upstash_redis
ioredis
node-redis
redis-py
go-redis
jedis
redis-rs