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#
| Argument | Required | Repeatable | Description |
|---|---|---|---|
username | Yes | No | ACL user to create or modify. |
rule | No | Yes | One rule token, applied in order. See the table below. |
| Rule | Effect |
|---|---|
on / off | Enable or disable authentication for the user. |
>token | Add a password. token must be a value returned by ACL GENTOKEN, not an arbitrary string. |
<token | Remove a password previously added this way. |
!hash | Remove a password by its 64-character lowercase SHA-256 hash. |
resetpass | Remove every password set on the user. |
~pattern | Grant access to keys matching pattern. |
allkeys | Alias for ~*. |
resetkeys | Remove every key pattern granted so far. |
&pattern | Grant access to pub/sub channels matching pattern. |
allchannels | Alias for &*. |
resetchannels | Remove every channel pattern granted so far. |
+command / -command | Grant or revoke a single command. |
+@category / -@category | Grant or revoke every command in a category; see ACL CAT. |
allcommands | Alias for +@all. |
nocommands | Alias for -@all. |
reset | Reset 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.
nopassis 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 withACL GENTOKENand added with>token; this is what lets the same credential authenticate on both the TCP and REST endpoints. - Subcommand-scoped rules such as
+client|listare not supported and return an error. - The
defaultuser 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 GETUSERbefore 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.
| Protocol | Reply |
|---|---|
| RESP2 | Simple string OK |
| RESP3 | Simple string OK |
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
This command is not supported yet in @upstash/redis.
upstash_redis
This command is not supported yet in upstash_redis.