Skip to main content
Workers KV is a global, low-latency key-value data store. The KV API allows you to manage namespaces, keys, and values.

Overview

Access the KV API:

Namespaces

KV namespaces are containers for key-value pairs.

Create a namespace

Create a new KV namespace.
string
required
Your Cloudflare account ID
string
required
A human-readable name for the namespace
string
The namespace ID (used for API operations)
string
The namespace title
boolean
Whether the namespace supports URL encoding for keys

List namespaces

Retrieve all KV namespaces in your account.
string
required
Your Cloudflare account ID
number
Page number for pagination
number
Number of namespaces per page (default: 20, max: 100)

Update a namespace

Rename a KV namespace.
string
required
The namespace ID to update
string
required
Your Cloudflare account ID
string
required
The new title for the namespace

Delete a namespace

Delete a KV namespace and all its key-value pairs.
string
required
The namespace ID to delete
string
required
Your Cloudflare account ID

Values

Manage key-value pairs within a namespace.

Write a value

Write a key-value pair to a namespace.
string
required
The namespace ID
string
required
The key name (up to 512 bytes)
string
required
Your Cloudflare account ID
string
required
The value to store (up to 25 MB)
object
Optional JSON metadata (up to 1024 bytes)
number
Unix timestamp when the key should expire
number
Number of seconds until the key expires

Read a value

Retrieve a value from a namespace.
string
required
The namespace ID
string
required
The key name to retrieve
string
required
Your Cloudflare account ID

Delete a value

Delete a key-value pair from a namespace.

Keys

List and manage keys within a namespace.

List keys

Retrieve a list of keys in a namespace.
string
required
The namespace ID
string
required
Your Cloudflare account ID
string
Filter keys by prefix
number
Maximum number of keys to return (default: 1000, max: 1000)
string
Pagination cursor for fetching the next page

Bulk operations

Bulk write

Write multiple key-value pairs in a single request.
string
required
The namespace ID
string
required
Your Cloudflare account ID
array
required
Array of key-value pairs to write (up to 10,000 pairs)

Bulk delete

Delete multiple keys in a single request.
string
required
The namespace ID
string
required
Your Cloudflare account ID
array
required
Array of key names to delete (up to 10,000 keys)

Metadata

Retrieve metadata about a key without fetching its value.
object
The JSON metadata associated with the key