{
  "schema_version": 2,
  "id": "commands/command-getkeys",
  "title": "COMMAND GETKEYS",
  "url": "https://redis.io/docs/latest/commands/command-getkeys/",
  "summary": "Extracts the key names from an arbitrary command.",
  "since": "2.8.13",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:48:09+01:00",
  "page_type": "content",
  "content_hash": "d878b7ec4aa8e9d7e417db6c35ee206406c7ad65fa096c4f05dd7cc9bd4eb109",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "`COMMAND GETKEYS` is a helper command to let you find the keys\nfrom the provided Redis `command`.\n\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 or [`COMMAND GETKEYSANDFLAGS`](https://redis.io/docs/latest/commands/command-getkeysandflags) to get the key names directly from the Redis command parser."
    },
    {
      "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 GETKEYS SORT mylist ALPHA STORE outlist\n1) \"mylist\"\n2) \"outlist\""
    },
    {
      "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): list of keys from the given command.\n\n**RESP3:**\n\n[Array reply](../../develop/reference/protocol-spec#arrays): a list of keys from the given command."
    }
  ],
  "examples": []
}
