# XPENDING

> Inspect the entries a consumer group has delivered but not yet acknowledged.

URL: https://docs.hotkv.com/commands/xpending/

```
XPENDING key group
XPENDING key group [IDLE min-idle-time] start end count [consumer]
```

- Group: Stream
- Complexity: O(N) for the entries returned (summary form O(C), C being the consumers)
- HotKV Cloud: all plans
- On-Premise: no license needed

`XPENDING` shows the pending entries list (PEL) of the consumer group `group`
on the stream `key`: entries that were delivered with
[XREADGROUP](https://docs.hotkv.com/commands/xreadgroup/index.md) and not yet acknowledged.

## Forms

**Summary** (`XPENDING key group`): the number of pending entries, the
lowest and highest pending ID, and how many entries each consumer holds.

**Extended** (`XPENDING key group start end count`): the pending entries
themselves, in ID order.

| Argument | Effect |
| --- | --- |
| `IDLE min-idle-time` | Only entries idle for at least this many milliseconds. |
| `start`, `end` | ID range, as for [XRANGE](https://docs.hotkv.com/commands/xrange/index.md): `-`, `+`, IDs, and `(` for exclusive bounds. |
| `count` | At most this many entries. 0 or less returns an empty array. |
| `consumer` | Only entries held by this consumer. |

## Return value

Summary form, an array of four elements:

| Element | Value |
| --- | --- |
| 1 | Integer: the number of pending entries |
| 2 | Bulk string: the lowest pending ID (nil when none) |
| 3 | Bulk string: the highest pending ID (nil when none) |
| 4 | Array of `[consumer, count]` pairs, the count as a bulk string (nil when none) |

Extended form, an array with one element per entry:
`[id, consumer, idle-milliseconds, delivery-count]`, the ID and consumer as
bulk strings and the last two as integers.

In RESP3 the nil values are nulls; the shapes are otherwise the same.

Error replies:

- `NOGROUP No such key 'key' or consumer group 'group'` when the stream or the group does not exist.
- `ERR syntax error` when the extended form is incomplete.
- `ERR value is not an integer or out of range`, `ERR Invalid stream ID specified as stream command argument`, or `WRONGTYPE`.

## Examples

```
127.0.0.1:6379> XADD tasks 1700000000000-0 job email
"1700000000000-0"
127.0.0.1:6379> XADD tasks 1700000000001-0 job sms
"1700000000001-0"
127.0.0.1:6379> XGROUP CREATE tasks workers 0
OK
127.0.0.1:6379> XPENDING tasks workers
1) (integer) 0
2) (nil)
3) (nil)
4) (nil)
127.0.0.1:6379> XREADGROUP GROUP workers alice STREAMS tasks >
1) 1) "tasks"
   2) 1) 1) "1700000000000-0"
         2) 1) "job"
            2) "email"
      2) 1) "1700000000001-0"
         2) 1) "job"
            2) "sms"
127.0.0.1:6379> XPENDING tasks workers
1) (integer) 2
2) "1700000000000-0"
3) "1700000000001-0"
4) 1) 1) "alice"
      2) "2"
127.0.0.1:6379> XPENDING tasks workers - + 10 alice
1) 1) "1700000000000-0"
   2) "alice"
   3) (integer) 5120
   4) (integer) 1
2) 1) "1700000000001-0"
   2) "alice"
   3) (integer) 5120
   4) (integer) 1
```

The idle times depend on when you run the command.

## Compatibility

Same as Redis 7 and Valkey 8, including the `IDLE` filter.

## See also

[XREADGROUP](https://docs.hotkv.com/commands/xreadgroup/index.md), [XACK](https://docs.hotkv.com/commands/xack/index.md), [XCLAIM](https://docs.hotkv.com/commands/xclaim/index.md),
[XAUTOCLAIM](https://docs.hotkv.com/commands/xautoclaim/index.md), [XINFO CONSUMERS](https://docs.hotkv.com/commands/xinfo-consumers/index.md)