# XDEL

> Delete entries from a stream by ID.

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

```
XDEL key id [id ...]
```

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

`XDEL` removes the entries with the given IDs from the stream at `key` and
returns how many it removed. IDs that are not in the stream are ignored.

Deleting entries does not change the stream's last generated ID, so new
entries still need higher IDs. An entry that is pending in a consumer group
stays in that group's pending list: reading the consumer's history with
[XREADGROUP](https://docs.hotkv.com/commands/xreadgroup/index.md) returns its ID with a nil body, and
[XCLAIM](https://docs.hotkv.com/commands/xclaim/index.md) and [XAUTOCLAIM](https://docs.hotkv.com/commands/xautoclaim/index.md) drop it.

All IDs are checked before anything is deleted, so one malformed ID fails the
whole call.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Stream exists | Integer: the number of entries deleted | Integer |
| Key does not exist | Integer `0` | Integer `0` |

Error replies: `ERR Invalid stream ID specified as stream command argument`,
and `WRONGTYPE` if the key holds another type.

## Examples

```
127.0.0.1:6379> XADD jobs 1700000000000-0 task resize
"1700000000000-0"
127.0.0.1:6379> XADD jobs 1700000000001-0 task upload
"1700000000001-0"
127.0.0.1:6379> XDEL jobs 1700000000000-0 1699000000000-0
(integer) 1
127.0.0.1:6379> XLEN jobs
(integer) 1
```

## Compatibility

Same as Redis 7 and Valkey 8.

## See also

[XTRIM](https://docs.hotkv.com/commands/xtrim/index.md), [XADD](https://docs.hotkv.com/commands/xadd/index.md), [XACK](https://docs.hotkv.com/commands/xack/index.md),
[XINFO STREAM](https://docs.hotkv.com/commands/xinfo-stream/index.md)