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:
Example
An example of deleting a key-value pair from within a Worker:
Reference
The following method is provided to delete from KV:
delete()
method
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:
Parameters
key
:string
- The key to associate with the value.
Response
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.
Guidance
Delete data in bulk
Delete more than one key-value pair at a time with Wrangler or via the API.
The bulk API can accept up to 10,000 KV pairs at once. Bulk writes are not supported using the KV binding.
Other methods to access KV
You can also delete key-value pairs from the command line with Wrangler or with the API.