Upstash Documentation

ACL GENTOKEN

Generate a REST token that can be used as a SETUSER password.
2 min read

Use ACL GENTOKEN to create the credential you need before you can give an ACL user a password.

ACL SETUSER does not accept arbitrary passwords with >password: the value must come from GENTOKEN. Call it with just a username to have a strong password generated for you, or supply your own password to wrap instead. Either way, the reply is a token string that does two things at once: pass it to SETUSER as >token to set the user's password, and later use it directly as UPSTASH_REDIS_REST_TOKEN, or exchange it (or the password it wraps) for a fresh one with ACL RESTTOKEN. GENTOKEN is an Upstash extension.

Syntax#

Arguments#

ArgumentRequiredRepeatableDescription
usernameYesNoACL user this token will belong to. The user does not need to exist yet.
passwordNoNoPassword to wrap in the token. When omitted, a strong random password is generated instead.

Important points#

  • A supplied password is checked for minimum entropy and rejected if too weak.
  • This only generates a token; it does not create or modify the user. Pass the result to ACL SETUSER <username> >token to actually set it as the user's password.

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
RESP2Bulk string
RESP3Bulk string
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
Note

This command is not supported yet in @upstash/redis.

upstash_redis
Note

This command is not supported yet in upstash_redis.

ioredis
node-redis
redis-py
go-redis
jedis
redis-rs