> ## Documentation Index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# ACL RESTTOKEN

> Generate a REST token for an existing user.

Use `ACL RESTTOKEN` to get a REST API token for an ACL user you already created, given that user's username and password.

The password is the same value used with `>password` in [`ACL SETUSER`](/docs/redis/commands/server/acl-setuser), which is itself a value produced by [`ACL GENTOKEN`](/docs/redis/commands/server/acl-gentoken); passing the full token string that `GENTOKEN` returned also works. The result is a bearer token scoped to that user's permissions that can be set as `UPSTASH_REDIS_REST_TOKEN`, which is how a database user created for TCP access is also given REST API access. `RESTTOKEN` is an Upstash extension.

## Syntax

```redis theme={"system"}
ACL RESTTOKEN <username> <password>
```

## Arguments

| Argument | Required | Repeatable | Description |
| - | - | - | - |
| `username` | Yes | No | Existing ACL user to generate a REST token for. |
| `password` | Yes | No | That user's password, as set with `>password` in `ACL SETUSER`. |

## Important points

* Returns an error if the username does not exist or the password does not match.
* The returned token carries the same permissions as the underlying user; revoking or narrowing the user with `ACL SETUSER` also affects every token issued for it.

## 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 | Bulk string |
| RESP3 | Bulk 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**
>
> ```bash theme={"system"}
> ACL RESTTOKEN app AQIDBAUGBwgJCgsMDQ4PEBESExQVFhc
> ```

> **@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**
>
> ```ts theme={"system"}
> import Redis from "ioredis";
>
> const redis = new Redis(process.env.REDIS_URL!);
> const result = await redis.acl("RESTTOKEN", "app", "AQIDBAUGBwgJCgsMDQ4PEBESExQVFhc");
> console.log(result);
> ```

> **node-redis**
>
> ```ts theme={"system"}
> import { createClient } from "redis";
>
> const client = await createClient({ url: process.env.REDIS_URL })
>   .on("error", console.error)
>   .connect();
> const result = await client.sendCommand(["ACL", "RESTTOKEN", "app", "AQIDBAUGBwgJCgsMDQ4PEBESExQVFhc"]);
> console.log(result);
> ```

> **redis-py**
>
> ```python theme={"system"}
> import os
> import redis
>
> client = redis.from_url(os.environ["REDIS_URL"])
> result = client.execute_command("ACL", "RESTTOKEN", "app", "AQIDBAUGBwgJCgsMDQ4PEBESExQVFhc")
> print(result)
> ```

> **go-redis**
>
> ```go theme={"system"}
> package main
>
> import (
>     "context"
>     "fmt"
>     "os"
>
>     "github.com/redis/go-redis/v9"
> )
>
> func main() {
>     opts, err := redis.ParseURL(os.Getenv("REDIS_URL"))
>     if err != nil {
>         panic(err)
>     }
>     client := redis.NewClient(opts)
>     result, err := client.Do(context.Background(), "ACL", "RESTTOKEN", "app", "AQIDBAUGBwgJCgsMDQ4PEBESExQVFhc").Result()
>     if err != nil {
>         panic(err)
>     }
>     fmt.Println(result)
> }
> ```

> **jedis**
>
> ```java theme={"system"}
> import java.net.URI;
> import java.nio.charset.StandardCharsets;
> import redis.clients.jedis.Jedis;
> import redis.clients.jedis.commands.ProtocolCommand;
>
> ProtocolCommand command = () -> "ACL".getBytes(StandardCharsets.UTF_8);
> try (Jedis jedis = new Jedis(new URI(System.getenv("REDIS_URL")))) {
>   Object result = jedis.sendCommand(command, "RESTTOKEN", "app", "AQIDBAUGBwgJCgsMDQ4PEBESExQVFhc");
>   System.out.println(result);
> }
> ```

> **redis-rs**
>
> ```rust theme={"system"}
> fn main() -> redis::RedisResult<()> {
>     let url = std::env::var("REDIS_URL").expect("REDIS_URL is not set");
>     let client = redis::Client::open(url)?;
>     let mut connection = client.get_connection()?;
>
>     let mut command = redis::cmd("ACL");
>     command.arg("RESTTOKEN");
>     command.arg("app");
>     command.arg("AQIDBAUGBwgJCgsMDQ4PEBESExQVFhc");
>     let result: redis::Value = command.query(&mut connection)?;
>     println!("{result:?}");
>     Ok(())
> }
> ```


## Related topics

- [ACL GENTOKEN](/docs/redis/commands/server/acl-gentoken.md)
- [REST API](/docs/redis/features/restapi.md)
- [Production Checklist](/docs/redis/help/production-checklist.md)
- [ACL SAVE](/docs/redis/commands/server/acl-save.md)
- [ACL LOAD](/docs/redis/commands/server/acl-load.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.