{
  "schema_version": 2,
  "id": "commands/xgroup-create",
  "title": "XGROUP CREATE",
  "url": "https://redis.io/docs/latest/commands/xgroup-create/",
  "summary": "Creates a consumer group.",
  "since": "5.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-06-15T06:26:34-07:00",
  "page_type": "content",
  "content_hash": "004750e52ba30dcced364c731e0936f238ebd57ece0d105b5ec4373f380cc5f4",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Create a new consumer group uniquely identified by `groupname` for the stream stored at `key`\n\nEvery group has a unique name in a given stream. \nWhen a consumer group with the same name already exists, the command returns a `-BUSYGROUP` error.\n\nThe command's `id` argument specifies the last delivered entry in the stream from the new group's perspective.\nThe special ID `$` is the ID of the last entry in the stream, but you can substitute it with any valid ID.\n\nFor example, if you want the group's consumers to fetch the entire stream from the beginning, use zero as the starting ID for the consumer group:\n\n    XGROUP CREATE mystream mygroup 0\n\nBy default, the `XGROUP CREATE` command expects that the target stream exists, and returns an error when it doesn't.\nIf a stream does not exist, you can create it automatically with length of 0 by using the optional `MKSTREAM` subcommand as the last argument after the `id`:\n\n    XGROUP CREATE mystream mygroup $ MKSTREAM\n\nTo enable consumer group lag tracking, specify the optional `entries_read` named argument with an arbitrary ID.\nAn arbitrary ID is any ID that isn't the ID of the stream's first entry, last entry, or zero (\"0-0\") ID.\nUse it to find out how many entries are between the arbitrary ID (excluding it) and the stream's last entry.\nSet the `entries_read` the stream's `entries_added` subtracted by the number of entries."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nThe stream key.\n\n</details>\n\n<details open><summary><code>group</code></summary>\n\nThe name of the consumer group to create.\n\n</details>\n\n<details open><summary><code>id | $</code></summary>\n\nThe ID of the last delivered message the group starts reading after. Use `$` for the last message currently in the stream, or `0` to read from the start.\n\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>MKSTREAM</code></summary>\n\nCreate the stream as an empty stream if it does not already exist.\n\n</details>\n\n<details open><summary><code>ENTRIESREAD entries-read</code></summary>\n\nSet the group's initial entries-read counter, used to compute its lag.\n\n</details>"
    },
    {
      "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[Simple string reply](../../develop/reference/protocol-spec#simple-strings): `OK`.\n\n**RESP3:**\n\n[Simple string reply](../../develop/reference/protocol-spec#simple-strings): `OK`."
    }
  ],
  "examples": []
}
