Skip to content
Start here

KV

KVNamespaces

List namespaces
GET/accounts/{account_id}/storage/kv/namespaces
Get a namespace
GET/accounts/{account_id}/storage/kv/namespaces/{namespace_id}
Create a namespace
POST/accounts/{account_id}/storage/kv/namespaces
Rename a namespace
PUT/accounts/{account_id}/storage/kv/namespaces/{namespace_id}
Delete a namespace
DELETE/accounts/{account_id}/storage/kv/namespaces/{namespace_id}
Write multiple key-value pairs
PUT/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk
Delete multiple key-value pairs
POST/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/delete
Get multiple key-value pairs
POST/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/get
ModelsExpand Collapse
Namespace object { id, title, jurisdiction, 2 more }
id: string

ID of the Workers KV namespace.

maxLength32
title: string

Human-readable string name for a Workers KV namespace.

maxLength512
jurisdiction: optional "eu" or "fedramp" or "us"

Specify the jurisdiction to restrict the KV namespace to durably store data within. Can only be set at namespace creation time.

One of the following:
"eu"
"fedramp"
"us"
mode: optional "instant"

The mode of the Workers KV namespace. Specify instant when creating a namespace to create a KV Instant namespace. Omit this field when creating a namespace to create a classic namespace. Currently, instant is the only supported explicit value.

supports_url_encoding: optional boolean

True if keys written on the URL will be URL-decoded before storing. For example, if set to “true”, a key written on the URL as “%3F” will be stored as ”?”.

NamespaceDeleteResponse object { }
NamespaceBulkUpdateResponse object { successful_key_count, unsuccessful_keys }
successful_key_count: optional number

Number of keys successfully written or deleted by the bulk operation.

unsuccessful_keys: optional array of string

Names of keys that failed to be written or deleted. Retry the operation for these keys.

NamespaceBulkDeleteResponse object { successful_key_count, unsuccessful_keys }
successful_key_count: optional number

Number of keys successfully written or deleted by the bulk operation.

unsuccessful_keys: optional array of string

Names of keys that failed to be written or deleted. Retry the operation for these keys.

NamespaceBulkGetResponse = object { values } or object { values }
One of the following:
WorkersKVBulkGetResult object { values }
values: optional map[string or number or boolean or map[unknown]]

Requested keys are paired with their values in an object.

One of the following:
string
number
boolean
map[unknown]
WorkersKVBulkGetResultWithMetadata object { values }
values: optional map[object { metadata, value, expiration } ]

Requested keys are paired with their values and metadata in an object.

metadata: unknown

The metadata associated with the key.

value: unknown

The value associated with the key.

expiration: optional number

Expires the key at a certain time, measured in number of seconds since the UNIX epoch.

KVNamespacesKeys

List keys in a namespace
GET/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/keys
Write multiple key-value pairs
Deprecated
PUT/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk
Delete multiple key-value pairs
Deprecated
POST/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/delete
Get multiple key-value pairs
Deprecated
POST/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/get
ModelsExpand Collapse
Key object { name, expiration, metadata }

A name for a value. A value stored under a given key may be retrieved via the same key.

name: string

A key’s name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid. Use percent-encoding to define key names as part of a URL.

maxLength512
expiration: optional number

The time, measured in number of seconds since the UNIX epoch, at which the key will expire. This property is omitted for keys that will not expire.

metadata: optional unknown

Arbitrary JSON that is associated with a key.

KeyBulkUpdateResponse object { successful_key_count, unsuccessful_keys }
successful_key_count: optional number

Number of keys successfully written or deleted by the bulk operation.

unsuccessful_keys: optional array of string

Names of keys that failed to be written or deleted. Retry the operation for these keys.

KeyBulkDeleteResponse object { successful_key_count, unsuccessful_keys }
successful_key_count: optional number

Number of keys successfully written or deleted by the bulk operation.

unsuccessful_keys: optional array of string

Names of keys that failed to be written or deleted. Retry the operation for these keys.

KeyBulkGetResponse = object { values } or object { values }
One of the following:
WorkersKVBulkGetResult object { values }
values: optional map[string or number or boolean or map[unknown]]

Requested keys are paired with their values in an object.

One of the following:
string
number
boolean
map[unknown]
WorkersKVBulkGetResultWithMetadata object { values }
values: optional map[object { metadata, value, expiration } ]

Requested keys are paired with their values and metadata in an object.

metadata: unknown

The metadata associated with the key.

value: unknown

The value associated with the key.

expiration: optional number

Expires the key at a certain time, measured in number of seconds since the UNIX epoch.

KVNamespacesMetadata

Get a key's metadata
GET/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/metadata/{key_name}
ModelsExpand Collapse
MetadataGetResponse = unknown

Arbitrary JSON that is associated with a key.

KVNamespacesValues

Get a key's value
GET/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}
Write a key-value pair with optional metadata
PUT/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}
Delete a key-value pair
DELETE/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}
ModelsExpand Collapse
ValueUpdateResponse object { }
ValueDeleteResponse object { }