Upstash Documentation

ACL SETUSER

Create or modify a user with the specified attributes.
3 min read

Use ACL SETUSER to create a new ACL user or change the rules of an existing one.

Rules are applied left to right in a single call: they enable or disable the user (on, off), grant or revoke access to key patterns (~pattern), channel patterns (&pattern), commands and categories (+get, -@admin), and manage passwords. Because rules are cumulative, calling SETUSER again only adds to or removes from what a user already has; use reset to start over from a clean slate.

Syntax#

Arguments#

ArgumentRequiredRepeatableDescription
usernameYesNoACL user to create or modify.
ruleNoYesOne rule token, applied in order. See the table below.
RuleEffect
on / offEnable or disable authentication for the user.
>tokenAdd a password. token must be a value returned by ACL GENTOKEN, not an arbitrary string.
<tokenRemove a password previously added this way.
!hashRemove a password by its 64-character lowercase SHA-256 hash.
resetpassRemove every password set on the user.
~patternGrant access to keys matching pattern.
allkeysAlias for ~*.
resetkeysRemove every key pattern granted so far.
&patternGrant access to pub/sub channels matching pattern.
allchannelsAlias for &*.
resetchannelsRemove every channel pattern granted so far.
+command / -commandGrant or revoke a single command.
+@category / -@categoryGrant or revoke every command in a category; see ACL CAT.
allcommandsAlias for +@all.
nocommandsAlias for -@all.
resetReset the user to its just-created state: resetpass, resetkeys, resetchannels, off, nocommands.

Important points#

  • This command can expose administrative information or make a broad destructive change. Restrict it to trusted code paths.
  • nopass is rejected. Every user must have at least one password; there is no way to allow authentication with any password.
  • Plain-text passwords (>password) and pre-hashed passwords (#hash) are rejected. Passwords must be generated with ACL GENTOKEN and added with >token; this is what lets the same credential authenticate on both the TCP and REST endpoints.
  • Subcommand-scoped rules such as +client|list are not supported and return an error.
  • The default user cannot be modified; the command returns an error if it is the target.
  • Changes take effect immediately on new and existing connections, so a rule that narrows access can lock out a running application. Check with ACL GETUSER before applying it broadly.

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
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