values
Creates, updates, deletes, gets or lists a values resource.
Overview
| Name | values |
| Type | Resource |
| Id | cloudflare.kv.values |
Fields
The following fields are returned by SELECT queries:
- get
Read key-value pair response.
| Name | Datatype | Description |
|---|---|---|
contents | string |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | key_name, namespace_id, account_id | Returns the value associated with the given key in the given namespace. Use URL-encoding to use special characters (for example, :, !, %) in the key name. If the KV-pair is set to expire at some point, the expiration time as measured in seconds since the UNIX epoch will be returned in the expiration response header. | |
update | replace | key_name, namespace_id, account_id | expiration, expiration_ttl | 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. |
delete | delete | key_name, namespace_id, account_id | Remove a KV pair from the namespace. Use URL-encoding to use special characters (for example, :, !, %) in the key name. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
account_id | string | The Cloudflare account ID. |
key_name | string | |
namespace_id | string | The Workers KV namespace ID. |
expiration | number | |
expiration_ttl | number |
SELECT examples
- get
Returns the value associated with the given key in the given namespace. Use URL-encoding to use special characters (for example, :, !, %) in the key name. If the KV-pair is set to expire at some point, the expiration time as measured in seconds since the UNIX epoch will be returned in the expiration response header.
SELECT
contents
FROM cloudflare.kv.values
WHERE key_name = '{{ key_name }}' -- required
AND namespace_id = '{{ namespace_id }}' -- required
AND account_id = '{{ account_id }}' -- required
;
REPLACE examples
- update
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.
REPLACE cloudflare.kv.values
SET
-- No updatable properties
WHERE
key_name = '{{ key_name }}' --required
AND namespace_id = '{{ namespace_id }}' --required
AND account_id = '{{ account_id }}' --required
AND expiration = '{{ expiration}}'
AND expiration_ttl = '{{ expiration_ttl}}'
RETURNING
errors,
messages,
result,
success;
DELETE examples
- delete
Remove a KV pair from the namespace. Use URL-encoding to use special characters (for example, :, !, %) in the key name.
DELETE FROM cloudflare.kv.values
WHERE key_name = '{{ key_name }}' --required
AND namespace_id = '{{ namespace_id }}' --required
AND account_id = '{{ account_id }}' --required
;