# COMMAND GETKEYSANDFLAGS

> Return the key arguments of a full command line, with whether each is read or written.

URL: https://docs.hotkv.com/commands/command-getkeysandflags/

```
COMMAND GETKEYSANDFLAGS command [argument ...]
```

- Group: Server
- Complexity: O(N) where N is the number of arguments
- HotKV Cloud: all plans
- On-Premise: no license needed

`COMMAND GETKEYSANDFLAGS` works like [COMMAND GETKEYS](https://docs.hotkv.com/commands/command-getkeys/index.md)
and also says how the command uses each key. Nothing is run.

## Return value

An array with one entry per key, each an array of the key and its flags, in
RESP2 and RESP3. The flags come from the command as a whole, so every key of
a command gets the same ones:

| Command | Flags |
| --- | --- |
| Reads data only | `RO`, `access` |
| Writes data | `OW`, `update` |
| Reads and writes data | `RW`, `access` |

The errors are those of [COMMAND GETKEYS](https://docs.hotkv.com/commands/command-getkeys/index.md).

## Examples

```
127.0.0.1:6379> COMMAND GETKEYSANDFLAGS GET user:1
1) 1) "user:1"
   2) 1) "RO"
      2) "access"
127.0.0.1:6379> COMMAND GETKEYSANDFLAGS SET user:1 alice
1) 1) "user:1"
   2) 1) "OW"
      2) "update"
```

## Compatibility

Same reply shape as Redis 7 and Valkey 8. Redis derives the flags of each
key from per-key specifications, so it can give different keys of one
command different flags (for example the source and destination of
[COPY](https://docs.hotkv.com/commands/copy/index.md)) and adds flags such as `insert` or `delete`. HotKV
gives every key of a command the same, coarser flags shown above.

## See also

[COMMAND GETKEYS](https://docs.hotkv.com/commands/command-getkeys/index.md), [COMMAND INFO](https://docs.hotkv.com/commands/command-info/index.md)