Search + K

Command Palette

Search for a command to run...

Sign In

Write multiple key-value pairs

PUT /accounts/{account_id}/storage/kv/namespaces/{namespace_id}/bulk
Copy endpoint
https://api.cloudflare.com/client/v4

Write multiple keys and values at once. Body should be an array of up to 10,000 key-value pairs to be stored, along with optional expiration information. Existing values and expirations will be overwritten. If neither expiration nor expiration_ttl is specified, the key-value pair will never expire. If both are set, expiration_ttl is used and expiration is ignored. The entire request size must be 100 megabytes or less.

Parameters

path Path Parameters

Name Type
namespace_id required
type WorkersKvNamespaceIdentifier = string
account_id required
type WorkersKvIdentifier = string

Request Body

application/json required
type WorkersKvBulkWrite = {
base64?: boolean;
expiration?: WorkersKvExpiration

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

type WorkersKvExpiration = number
;
expiration_ttl?: WorkersKvExpirationTtl

Expires the key after a number of seconds. Must be at least 60.

type WorkersKvExpirationTtl = number
;
key: WorkersKvKeyNameBulk

A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid.

type WorkersKvKeyNameBulk = string
;
metadata?: WorkersKvListMetadata
type WorkersKvListMetadata = WorkersKvAny
;
value: string;
}
[]

Responses

200 application/json

Write multiple key-value pairs response.

type WorkersKvApiResponseCommonNoResult = interface WorkersKvApiResponseCommon {
errors: WorkersKvMessages
type WorkersKvMessages = { code: number;message: string; }[]
;
messages: WorkersKvMessages
type WorkersKvMessages = { code: number;message: string; }[]
;
success: true;
}
& { result?: {} | null; }
& { result?: WorkersKvBulkResult
interface WorkersKvBulkResult {
successful_key_count?: number;
unsuccessful_keys?: string[];
}
; }

Client Errors

4XX application/json

Write multiple key-value pairs response failure.

type WorkersKvApiResponseCommonNoResult = interface WorkersKvApiResponseCommon {
errors: WorkersKvMessages
type WorkersKvMessages = { code: number;message: string; }[]
;
messages: WorkersKvMessages
type WorkersKvMessages = { code: number;message: string; }[]
;
success: true;
}
& { result?: {} | null; }
& { result?: WorkersKvBulkResult
interface WorkersKvBulkResult {
successful_key_count?: number;
unsuccessful_keys?: string[];
}
; }