{
  "schema_version": 2,
  "id": "commands/command-getkeysandflags",
  "title": "COMMAND GETKEYSANDFLAGS",
  "url": "https://redis.io/docs/latest/commands/command-getkeysandflags/",
  "summary": "Extracts the key names and access flags for an arbitrary command.",
  "since": "7.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:48:09+01:00",
  "page_type": "content",
  "content_hash": "5ff8d8465e0c9a651d45c216e63c63274b6ecb3be8b12c2b5b01a982d83908f5",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "`COMMAND GETKEYSANDFLAGS` is a helper command to let you find the keys from a full Redis `command`, together with flags that indicate what each key is used for.\n\n[COMMAND](https://redis.io/docs/latest/commands/command) describes how Redis identifies key names for each command, including `firstkey`, [key specifications](https://redis.io/docs/latest/develop/reference/key-specs#logical-operation-flags), and `movablekeys`. For some commands, Redis can identify the keys only by parsing the full command. Use [COMMAND GETKEYS](https://redis.io/docs/latest/commands/command-getkeys) or COMMAND GETKEYSANDFLAGS to get key names directly from the Redis command parser.\n\nRefer to [key specifications](https://redis.io/docs/latest/develop/reference/key-specs#logical-operation-flags) for information about the meaning of the key flags."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>command</code></summary>\n\nThe name of the command to analyze.\n\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>arg [arg ...]</code></summary>\n\nThe arguments that would be passed to the command.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> COMMAND GETKEYS MSET a b c d e f\n1) \"a\"\n2) \"c\"\n3) \"e\"\nredis> COMMAND GETKEYS EVAL \"not consulted\" 3 key1 key2 key3 arg1 arg2 arg3 argN\n1) \"key1\"\n2) \"key2\"\n3) \"key3\"\nredis> COMMAND GETKEYSANDFLAGS LMOVE mylist1 mylist2 left left\n1) 1) \"mylist1\"\n   2) 1) RW\n      2) access\n      3) delete\n2) 1) \"mylist2\"\n   2) 1) RW\n      2) insert"
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\n[Array reply](../../develop/reference/protocol-spec#arrays): a list of keys from the given command and their usage flags.\n\n**RESP3:**\n\n[Array reply](../../develop/reference/protocol-spec#arrays): a list of keys from the given command and their usage flags."
    }
  ],
  "examples": []
}
