Search + K

Command Palette

Search for a command to run...

Sign In

Write key-value pair with optional metadata

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

Write a value identified by a key. Use URL-encoding to use special characters (for example, :, !, %) in the key name. Body should be the value to be stored. If JSON metadata to be associated with the key/value pair is needed, use multipart/form-data content type for your PUT request (see dropdown below in REQUEST BODY SCHEMA). Existing values, expirations, and metadata 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.

Parameters

path Path Parameters

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

query Query Parameters

Name Type
expiration
type WorkersKvExpiration = number
expiration_ttl
type WorkersKvExpirationTtl = number

Request Body

application/octet-stream required
type WorkersKvValue = string

Responses

200 application/json

Write key-value pair with metadata 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; }

Client Errors

4XX application/json

Write key-value pair with metadata response failure.

interface WorkersKvApiResponseCommonFailure {
errors: WorkersKvMessages
type WorkersKvMessages = { code: number;message: string; }[]
;
messages: WorkersKvMessages
type WorkersKvMessages = { code: number;message: string; }[]
;
result: {} | null;
success: false;
}