Skip to content
Start here

KV

KVNamespaces

List namespaces
client.kv.namespaces.list(NamespaceListParams { account_id, direction, order, 2 more } params, RequestOptionsoptions?): V4PagePaginationArray<Namespace { id, title, jurisdiction, 2 more } >
GET/accounts/{account_id}/storage/kv/namespaces
Get a namespace
client.kv.namespaces.get(stringnamespaceID, NamespaceGetParams { account_id } params, RequestOptionsoptions?): Namespace { id, title, jurisdiction, 2 more }
GET/accounts/{account_id}/storage/kv/namespaces/{namespace_id}
Create a namespace
client.kv.namespaces.create(NamespaceCreateParams { account_id, title, jurisdiction, mode } params, RequestOptionsoptions?): Namespace { id, title, jurisdiction, 2 more }
POST/accounts/{account_id}/storage/kv/namespaces
Rename a namespace
client.kv.namespaces.update(stringnamespaceID, NamespaceUpdateParams { account_id, title } params, RequestOptionsoptions?): Namespace { id, title, jurisdiction, 2 more }
PUT/accounts/{account_id}/storage/kv/namespaces/{namespace_id}
Delete a namespace
client.kv.namespaces.delete(stringnamespaceID, NamespaceDeleteParams { account_id } params, RequestOptionsoptions?): NamespaceDeleteResponse | null
DELETE/accounts/{account_id}/storage/kv/namespaces/{namespace_id}
Write multiple key-value pairs
client.kv.namespaces.bulkUpdate(stringnamespaceID, NamespaceBulkUpdateParams { account_id, body } params, RequestOptionsoptions?): NamespaceBulkUpdateResponse { successful_key_count, unsuccessful_keys } | null
PUT/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk
Delete multiple key-value pairs
client.kv.namespaces.bulkDelete(stringnamespaceID, NamespaceBulkDeleteParams { account_id, body } params, RequestOptionsoptions?): NamespaceBulkDeleteResponse { successful_key_count, unsuccessful_keys } | null
POST/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/delete
Get multiple key-value pairs
client.kv.namespaces.bulkGet(stringnamespaceID, NamespaceBulkGetParams { account_id, keys, type, withMetadata } params, RequestOptionsoptions?): NamespaceBulkGetResponse | null
POST/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/get
ModelsExpand Collapse
Namespace { 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?: "eu" | "fedramp" | "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?: "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?: 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
NamespaceBulkUpdateResponse { successful_key_count, unsuccessful_keys }
successful_key_count?: number

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

unsuccessful_keys?: Array<string>

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

NamespaceBulkDeleteResponse { successful_key_count, unsuccessful_keys }
successful_key_count?: number

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

unsuccessful_keys?: Array<string>

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

NamespaceBulkGetResponse = WorkersKVBulkGetResult { values } | WorkersKVBulkGetResultWithMetadata { values } | null
One of the following:
WorkersKVBulkGetResult { values }
values?: Record<string, string | number | boolean | Record<string, unknown>>

Requested keys are paired with their values in an object.

One of the following:
string
number
boolean
Record<string, unknown>
WorkersKVBulkGetResultWithMetadata { values }
values?: Record<string, Values | null>

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?: number

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

KVNamespacesKeys

List keys in a namespace
client.kv.namespaces.keys.list(stringnamespaceID, KeyListParams { account_id, cursor, limit, prefix } params, RequestOptionsoptions?): CursorLimitPagination<Key { name, expiration, metadata } >
GET/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/keys
Write multiple key-value pairs
Deprecated
client.kv.namespaces.keys.bulkUpdate(stringnamespaceID, KeyBulkUpdateParams { account_id, body } params, RequestOptionsoptions?): KeyBulkUpdateResponse { successful_key_count, unsuccessful_keys } | null
PUT/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk
Delete multiple key-value pairs
Deprecated
client.kv.namespaces.keys.bulkDelete(stringnamespaceID, KeyBulkDeleteParams { account_id, body } params, RequestOptionsoptions?): KeyBulkDeleteResponse { successful_key_count, unsuccessful_keys } | null
POST/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/delete
Get multiple key-value pairs
Deprecated
client.kv.namespaces.keys.bulkGet(stringnamespaceID, KeyBulkGetParams { account_id, keys, type, withMetadata } params, RequestOptionsoptions?): KeyBulkGetResponse | null
POST/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk/get
ModelsExpand Collapse
Key { 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?: 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?: unknown

Arbitrary JSON that is associated with a key.

KeyBulkUpdateResponse { successful_key_count, unsuccessful_keys }
successful_key_count?: number

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

unsuccessful_keys?: Array<string>

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

KeyBulkDeleteResponse { successful_key_count, unsuccessful_keys }
successful_key_count?: number

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

unsuccessful_keys?: Array<string>

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

KeyBulkGetResponse = WorkersKVBulkGetResult { values } | WorkersKVBulkGetResultWithMetadata { values } | null
One of the following:
WorkersKVBulkGetResult { values }
values?: Record<string, string | number | boolean | Record<string, unknown>>

Requested keys are paired with their values in an object.

One of the following:
string
number
boolean
Record<string, unknown>
WorkersKVBulkGetResultWithMetadata { values }
values?: Record<string, Values | null>

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?: number

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

KVNamespacesMetadata

Get a key's metadata
client.kv.namespaces.metadata.get(stringkeyName, MetadataGetParams { account_id, namespace_id } params, RequestOptionsoptions?): MetadataGetResponse
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
client.kv.namespaces.values.get(stringkeyName, ValueGetParams { account_id, namespace_id } params, RequestOptionsoptions?): Response
GET/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}
Write a key-value pair with optional metadata
client.kv.namespaces.values.update(stringkeyName, ValueUpdateParams { account_id, namespace_id, value, 3 more } params, RequestOptionsoptions?): ValueUpdateResponse | null
PUT/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}
Delete a key-value pair
client.kv.namespaces.values.delete(stringkeyName, ValueDeleteParams { account_id, namespace_id } params, RequestOptionsoptions?): ValueDeleteResponse | null
DELETE/accounts/{account_id}/storage/kv/namespaces/{namespace_id}/values/{key_name}
ModelsExpand Collapse
ValueUpdateResponse
ValueDeleteResponse