WorkerWorkers Kv Namespace

Write key-value pair with metadata

PUT

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 along with JSON metadata to be associated with the key/value pair. 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.

Path parameters

key_namestringRequired
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.
namespace_identifierstringRequired
Namespace identifier tag.
account_identifierstringRequired
Identifier

Request

This endpoint expects an object.
metadata
stringRequired
Arbitrary JSON to be associated with a key/value pair.
value
stringRequired
A byte sequence to be stored, up to 25 MiB in length.

Response

This endpoint returns an object
result
unionOptional
PUT
1curl -X PUT https://api.cloudflare.com/client/v4/accounts/:account_identifier/storage/kv/namespaces/:namespace_identifier/values/:key_name \
2 -H "X-Auth-Key: string" \
3 -H "X-Auth-User-Service-Key: string" \
4 -H "Authorization: Bearer <token>" \
5 -H "Content-Type: application/json" \
6 -d '{
7 "metadata": "string",
8 "value": "string"
9}'
200Updated
1{
2 "result": {
3 "string": {}
4 }
5}