---
title: "DeleteRange deletes the given range from the key-value store. A delete request increments the revision of the key-value store and generates a delete event in the event history for every deleted key."
method: POST
path: "/v3/kv/deleterange"
tags: ["KV"]
---

# DeleteRange deletes the given range from the key-value store. A delete request increments the revision of the key-value store and generates a delete event in the event history for every deleted key.

`POST /v3/kv/deleterange`

## Request

- Base URL: `https://etcd.io` (the document declares no server; this is the origin it was published from)
- URL: `https://etcd.io/v3/kv/deleterange`
- Auth: API key in header `Authorization`
- TypeScript: <https://skmtc.dev/etcd/apis/api-etcdserverpb-rpc-proto/docs/v3/kv/deleterange/post.ts> (a function with typed inputs; its response is checked against the schema)

## Request body

- EtcdserverpbDeleteRangeRequest
  - `key` string, byte: key is the first key to delete in the range.
  - `prev_kv` boolean: If prev_kv is set, etcd gets the previous key-value pairs before deleting it. The previous key-value pairs will be returned in the delete response.
  - `range_end` string, byte: range_end is the key following the last key to delete for the range [key, range_end). If range_end is not given, the range is defined to contain only the key argument. If range_end is one bit larger than the given key, then the range is all the keys with the prefix (the given key). If range_end is '\0', the range is all keys greater than or equal to the key argument.

## Response `200`

A successful response.

- EtcdserverpbDeleteRangeResponse
  - `deleted` string, int64: deleted is the number of keys deleted by the delete range request.
  - `header` EtcdserverpbResponseHeader
    - `cluster_id` string, uint64: cluster_id is the ID of the cluster which sent the response.
    - `member_id` string, uint64: member_id is the ID of the member which sent the response.
    - `raft_term` string, uint64: raft_term is the raft term when the request was applied.
    - `revision` string, int64: revision is the key-value store revision when the request was applied. For watch progress responses, the header.revision indicates progress. All future events recieved in this stream are guaranteed to have a higher revision number than the header.revision number.
  - `prev_kvs` MvccpbKeyValue[]: if prev_kv is set in the request, the previous key-value pairs will be returned.
    - `create_revision` string, int64: create_revision is the revision of last creation on this key.
    - `key` string, byte: key is the key in bytes. An empty key is not allowed.
    - `lease` string, int64: lease is the ID of the lease that attached to key. When the attached lease expires, the key will be deleted. If lease is 0, then no lease is attached to the key.
    - `mod_revision` string, int64: mod_revision is the revision of last modification on this key.
    - `value` string, byte: value is the value held by the key, in bytes.
    - `version` string, int64: version is the version of the key. A deletion resets the version to zero and any modification of the key increases its version.

## Other responses

- `default`: An unexpected error response

---

[API](https://skmtc.dev/etcd/apis/api-etcdserverpb-rpc-proto.md) - [All operations](https://skmtc.dev/etcd/apis/api-etcdserverpb-rpc-proto/llms.txt) - [OpenAPI document](https://skmtc.dev/etcd/apis/api-etcdserverpb-rpc-proto/revisions/79259377f328?raw)
