PHP Client for Cloudflare API
Workers

KV

KV endpoint reference.

List

Returns the namespaces owned by an account.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
paramsarrayNo[]Array containing the necessary params.
php
$response = $client->workers()->kv()->list('ACCOUNT_ID', []);
View this operation on the Cloudflare API Reference

Create

Creates a namespace under the given title. A 400 is returned if the account already owns a namespace with this title. A namespace must be explicitly deleted to be replaced.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
titlestringYesA human-readable string name for a Namespace.
php
$response = $client->workers()->kv()->create('ACCOUNT_ID', 'TITLE');
View this operation on the Cloudflare API Reference

Get

Get the namespace corresponding to the given ID.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
namespaceIdstringYesNamespace identifier tag.
php
$response = $client->workers()->kv()->get('ACCOUNT_ID', 'NAMESPACE_ID');
View this operation on the Cloudflare API Reference

Update

Modifies a namespace's title.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
namespaceIdstringYesNamespace identifier tag.
titlestringYesA human-readable string name for a Namespace.
php
$response = $client->workers()->kv()->update('ACCOUNT_ID', 'NAMESPACE_ID', 'TITLE');
View this operation on the Cloudflare API Reference

Delete

Deletes the namespace corresponding to the given ID.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
namespaceIdstringYesNamespace identifier tag.
php
$response = $client->workers()->kv()->delete('ACCOUNT_ID', 'NAMESPACE_ID');
View this operation on the Cloudflare API Reference

List Keys

Lists a namespace keys.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
namespaceIdstringYesNamespace identifier tag.
paramsarrayNo[]Array containing the necessary params.
php
$response = $client->workers()->kv()->listKeys('ACCOUNT_ID', 'NAMESPACE_ID', []);
View this operation on the Cloudflare API Reference

Key Metadata

Returns the metadata associated with the given key in the given namespace. Use URL-encoding to use special characters (for example, :, !, %) in the key name.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
namespaceIdstringYesNamespace identifier tag.
keyNamestringYesA 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.
php
$response = $client->workers()->kv()->keyMetadata('ACCOUNT_ID', 'NAMESPACE_ID', 'KEY_NAME');
View this operation on the Cloudflare API Reference

Key Details

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.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
namespaceIdstringYesNamespace identifier tag.
keyNamestringYesA 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.
php
$response = $client->workers()->kv()->keyDetails('ACCOUNT_ID', 'NAMESPACE_ID', 'KEY_NAME');
View this operation on the Cloudflare API Reference

Write Key With Metadata

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.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
namespaceIdstringYesNamespace identifier tag.
keyNamestringYesA 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.
valuesarrayYeskeys and values.
php
$response = $client->workers()->kv()->writeKeyWithMetadata('ACCOUNT_ID', 'NAMESPACE_ID', 'KEY_NAME', []);
View this operation on the Cloudflare API Reference

Delete Key

Remove multiple KV pairs from the namespace. Body should be an array of up to 10,000 keys to be removed.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
namespaceIdstringYesNamespace identifier tag.
keyNamestringYesA 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.
php
$response = $client->workers()->kv()->deleteKey('ACCOUNT_ID', 'NAMESPACE_ID', 'KEY_NAME');
View this operation on the Cloudflare API Reference

Write Multiple Keys

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.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
namespaceIdstringYesNamespace identifier tag.
valuesarrayYeskeys and values.
php
$response = $client->workers()->kv()->writeMultipleKeys('ACCOUNT_ID', 'NAMESPACE_ID', []);
View this operation on the Cloudflare API Reference

Delete Multiple Keys

Remove multiple KV pairs from the namespace. Body should be an array of up to 10,000 keys to be removed.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
namespaceIdstringYesNamespace identifier tag.
keysarrayYesKeys.
php
$response = $client->workers()->kv()->deleteMultipleKeys('ACCOUNT_ID', 'NAMESPACE_ID', []);
View this operation on the Cloudflare API Reference
Copyright © 2026