Write a key-value pair with optional metadata
Writes a value under the specified key in the Workers KV namespace, creating the key-value pair or replacing its existing value, expiration, and metadata. Send the value as an application/octet-stream request body, or use multipart/form-data with a value part and an optional JSON metadata part. Use URL-encoding for special characters (for example, :, !, %) in the key name when constructing the request URL. If neither expiration nor expiration_ttl is specified, the key-value pair will not expire. If both are set, expiration_ttl takes precedence.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Accepted Permissions (at least one required)
Parameters
Write a key-value pair with optional metadata
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const value = await client.kv.namespaces.values.update('My-Key', {
account_id: '023e105f4ecef8ad9ca31a8372d0c353',
namespace_id: '0f2ac74b498b48028cb68387c421e279',
value: 'Some Value',
});
console.log(value);{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true,
"result": {}
}Returns Examples
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"success": true,
"result": {}
}