Delete key-value pairs
To delete a key-value pair, call the delete()
method of the KV binding on any KV namespace you have bound to your Worker code:
An example of deleting a key-value pair from within a Worker:
The following method is provided to delete from KV:
To delete a key-value pair, call the delete()
method of the KV binding on any KV namespace you have bound to your Worker code:
key
:string
- The key to associate with the value.
response
:Promise<void>
- A
Promise
that resolves if the delete is successful.
- A
This method returns a promise that you should await
on to verify successful deletion. Calling delete()
on a non-existing key is returned as a successful delete.
Calling the delete()
method will remove the key and value from your KV namespace. As with any operations, it may take some time for the key to be deleted from various points in the Cloudflare global network.
Delete more than one key-value pair at a time with Wrangler or via the REST API.
The bulk REST API can accept up to 10,000 KV pairs at once. Bulk writes are not supported using the KV binding.
You can also delete key-value pairs from the command line with Wrangler or with the REST API.