# XGROUP CREATECONSUMER

> Add a consumer to a stream consumer group ahead of its first read.

URL: https://docs.hotkv.com/commands/xgroup-createconsumer/

```
XGROUP CREATECONSUMER key group consumer
```

- Group: Stream
- Complexity: O(1)
- HotKV Cloud: all plans
- On-Premise: no license needed

`XGROUP CREATECONSUMER` adds `consumer` to the consumer group `group` on the
stream at `key`. You rarely need it: [XREADGROUP](https://docs.hotkv.com/commands/xreadgroup/index.md),
[XCLAIM](https://docs.hotkv.com/commands/xclaim/index.md) and [XAUTOCLAIM](https://docs.hotkv.com/commands/xautoclaim/index.md) create the
consumer on first use.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Consumer created | Integer `1` | Integer `1` |
| Consumer already existed | Integer `0` | Integer `0` |

Error replies:

- `NOGROUP No such consumer group 'group' for key name 'key'`
- `ERR The XGROUP subcommand requires the key to exist. ...` when the stream does not exist.
- `WRONGTYPE` if the key holds another type.

## Examples

```
127.0.0.1:6379> XGROUP CREATE orders billing $ MKSTREAM
OK
127.0.0.1:6379> XGROUP CREATECONSUMER orders billing worker-1
(integer) 1
127.0.0.1:6379> XGROUP CREATECONSUMER orders billing worker-1
(integer) 0
```

## Compatibility

Same as Redis 7 and Valkey 8.

## See also

[XGROUP DELCONSUMER](https://docs.hotkv.com/commands/xgroup-delconsumer/index.md), [XINFO CONSUMERS](https://docs.hotkv.com/commands/xinfo-consumers/index.md),
[XGROUP](https://docs.hotkv.com/commands/xgroup/index.md)