Skip to main content
Reference vendor/cloudflare 2 min read

api

KV API Reference

Read the relevant API page before implementing; it defines current options, result shapes, supported bulk operations, and constraints.

TaskDocumentation
Read one or several keys; choose text, JSON, binary, or stream resultsRead key-value pairs
Read metadata with values; tune read caching or coalesce related keysRead guidance
Write values and metadata; set absolute expiration or a relative lifetimeWrite key-value pairs
Delete a keyDelete key-value pairs
Enumerate keys, filter by prefix, and paginateList keys
Access namespaces or perform bulk operations outside a WorkerKV REST API and Wrangler KV commands

Handle missing values explicitly: JavaScript reads return null for absent keys; valid stored values can be falsy. Choose defaults separately from how you handle request failures.

For pagination, follow the returned cursor until list_complete is true, even if a page has no keys. Preserve the original prefix on subsequent calls. Listing returns key information, not stored values; use the listing guide to decide whether metadata avoids additional reads.

Use gotchas.md for consistency and contention decisions before adding retries or read-after-write verification.