---
title: KV
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api/python)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# KV

#### KVNamespaces

##### [List namespaces](https://developers.cloudflare.com/api/python/resources/kv/subresources/namespaces/methods/list)

kv.namespaces.list(NamespaceListParams\*\*kwargs) -> SyncV4PagePaginationArray\[[Namespace](<https://developers.cloudflare.com/api/python/resources/kv#(resource)%20kv.namespaces%20%3E%20(model)%20namespace%20%3E%20(schema)>)]

GET/accounts/{account\_id}/storage/kv/namespaces

##### [Get a namespace](https://developers.cloudflare.com/api/python/resources/kv/subresources/namespaces/methods/get)

kv.namespaces.get(strnamespace\_id, NamespaceGetParams\*\*kwargs) -> [Namespace](<https://developers.cloudflare.com/api/python/resources/kv#(resource)%20kv.namespaces%20%3E%20(model)%20namespace%20%3E%20(schema)>)

GET/accounts/{account\_id}/storage/kv/namespaces/{namespace\_id}

##### [Create a namespace](https://developers.cloudflare.com/api/python/resources/kv/subresources/namespaces/methods/create)

kv.namespaces.create(NamespaceCreateParams\*\*kwargs) -> [Namespace](<https://developers.cloudflare.com/api/python/resources/kv#(resource)%20kv.namespaces%20%3E%20(model)%20namespace%20%3E%20(schema)>)

POST/accounts/{account\_id}/storage/kv/namespaces

##### [Rename a namespace](https://developers.cloudflare.com/api/python/resources/kv/subresources/namespaces/methods/update)

kv.namespaces.update(strnamespace\_id, NamespaceUpdateParams\*\*kwargs) -> [Namespace](<https://developers.cloudflare.com/api/python/resources/kv#(resource)%20kv.namespaces%20%3E%20(model)%20namespace%20%3E%20(schema)>)

PUT/accounts/{account\_id}/storage/kv/namespaces/{namespace\_id}

##### [Delete a namespace](https://developers.cloudflare.com/api/python/resources/kv/subresources/namespaces/methods/delete)

kv.namespaces.delete(strnamespace\_id, NamespaceDeleteParams\*\*kwargs) -> [NamespaceDeleteResponse](<https://developers.cloudflare.com/api/python/resources/kv#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_delete_response%20%3E%20(schema)>)

DELETE/accounts/{account\_id}/storage/kv/namespaces/{namespace\_id}

##### [Write multiple key-value pairs](https://developers.cloudflare.com/api/python/resources/kv/subresources/namespaces/methods/bulk_update)

kv.namespaces.bulk\_update(strnamespace\_id, NamespaceBulkUpdateParams\*\*kwargs) -> [NamespaceBulkUpdateResponse](<https://developers.cloudflare.com/api/python/resources/kv#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_update_response%20%3E%20(schema)>)

PUT/accounts/{account\_id}/storage/kv/namespaces/{namespace\_id}/bulk

##### [Delete multiple key-value pairs](https://developers.cloudflare.com/api/python/resources/kv/subresources/namespaces/methods/bulk_delete)

kv.namespaces.bulk\_delete(strnamespace\_id, NamespaceBulkDeleteParams\*\*kwargs) -> [NamespaceBulkDeleteResponse](<https://developers.cloudflare.com/api/python/resources/kv#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_delete_response%20%3E%20(schema)>)

POST/accounts/{account\_id}/storage/kv/namespaces/{namespace\_id}/bulk/delete

##### [Get multiple key-value pairs](https://developers.cloudflare.com/api/python/resources/kv/subresources/namespaces/methods/bulk_get)

kv.namespaces.bulk\_get(strnamespace\_id, NamespaceBulkGetParams\*\*kwargs) -> [NamespaceBulkGetResponse](<https://developers.cloudflare.com/api/python/resources/kv#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_get_response%20%3E%20(schema)>)

POST/accounts/{account\_id}/storage/kv/namespaces/{namespace\_id}/bulk/get

##### ModelsExpand Collapse

<details>

<summary>

class Namespace: …

</summary>

id: str

ID of the Workers KV namespace.

maxLength32

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

title: str

Human-readable string name for a Workers KV namespace.

maxLength512

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace%20%3E%20(schema)%20%3E%20(property)%20title">Link to this property</a>

<details>

<summary>

jurisdiction: Optional\[Literal\["eu", "fedramp", "us"]]

Specify the jurisdiction to restrict the KV namespace to durably store data within. Can only be set at namespace creation time.

</summary>

One of the following:

"eu"

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace%20%3E%20(schema)%20%3E%20(property)%20jurisdiction%20%3E%20(member)%200">Link to this property</a>

"fedramp"

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace%20%3E%20(schema)%20%3E%20(property)%20jurisdiction%20%3E%20(member)%201">Link to this property</a>

"us"

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace%20%3E%20(schema)%20%3E%20(property)%20jurisdiction%20%3E%20(member)%202">Link to this property</a>

</details>

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace%20%3E%20(schema)%20%3E%20(property)%20jurisdiction">Link to this property</a>

mode: Optional\[Literal\["instant"]]

The mode of the Workers KV namespace. Specify <code>instant</code> when creating a namespace to create a KV Instant namespace. Omit this field when creating a namespace to create a classic namespace. Currently, <code>instant</code> is the only supported explicit value.

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace%20%3E%20(schema)%20%3E%20(property)%20mode">Link to this property</a>

supports\_url\_encoding: Optional\[bool]

True if keys written on the URL will be URL-decoded before storing. For example, if set to “true”, a key written on the URL as “%3F” will be stored as ”?”.

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace%20%3E%20(schema)%20%3E%20(property)%20supports_url_encoding">Link to this property</a>

</details>

[Link to this property](<#(resource)%20kv.namespaces%20%3E%20(model)%20namespace%20%3E%20(schema)>)

class NamespaceDeleteResponse: …

[Link to this property](<#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_delete_response%20%3E%20(schema)>)

<details>

<summary>

class NamespaceBulkUpdateResponse: …

</summary>

successful\_key\_count: Optional\[float]

Number of keys successfully written or deleted by the bulk operation.

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_update_response%20%3E%20(schema)%20%3E%20(property)%20successful_key_count">Link to this property</a>

unsuccessful\_keys: Optional\[List\[str]]

Names of keys that failed to be written or deleted. Retry the operation for these keys.

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_update_response%20%3E%20(schema)%20%3E%20(property)%20unsuccessful_keys">Link to this property</a>

</details>

[Link to this property](<#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_update_response%20%3E%20(schema)>)

<details>

<summary>

class NamespaceBulkDeleteResponse: …

</summary>

successful\_key\_count: Optional\[float]

Number of keys successfully written or deleted by the bulk operation.

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_delete_response%20%3E%20(schema)%20%3E%20(property)%20successful_key_count">Link to this property</a>

unsuccessful\_keys: Optional\[List\[str]]

Names of keys that failed to be written or deleted. Retry the operation for these keys.

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_delete_response%20%3E%20(schema)%20%3E%20(property)%20unsuccessful_keys">Link to this property</a>

</details>

[Link to this property](<#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_delete_response%20%3E%20(schema)>)

<details>

<summary>

Optional\[NamespaceBulkGetResponse]

</summary>

One of the following:

<details>

<summary>

class WorkersKVBulkGetResult: …

</summary>

<details>

<summary>

values: Optional\[Dict\[str, Union\[str, float, bool, Dict\[str, object]]]]

Requested keys are paired with their values in an object.

</summary>

One of the following:

str

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%200%20%3E%20(property)%20values%20%3E%20(items)%20%3E%20(variant)%200">Link to this property</a>

float

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%200%20%3E%20(property)%20values%20%3E%20(items)%20%3E%20(variant)%201">Link to this property</a>

bool

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%200%20%3E%20(property)%20values%20%3E%20(items)%20%3E%20(variant)%202">Link to this property</a>

Dict\[str, object]

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%200%20%3E%20(property)%20values%20%3E%20(items)%20%3E%20(variant)%203">Link to this property</a>

</details>

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%200%20%3E%20(property)%20values">Link to this property</a>

</details>

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%200">Link to this property</a>

<details>

<summary>

class WorkersKVBulkGetResultWithMetadata: …

</summary>

<details>

<summary>

values: Optional\[Dict\[str, Optional\[WorkersKVBulkGetResultWithMetadataValues]]]

Requested keys are paired with their values and metadata in an object.

</summary>

metadata: object

The metadata associated with the key.

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20values%20%3E%20(items)%20%3E%20(property)%20metadata">Link to this property</a>

value: object

The value associated with the key.

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20values%20%3E%20(items)%20%3E%20(property)%20value">Link to this property</a>

expiration: Optional\[float]

Expires the key at a certain time, measured in number of seconds since the UNIX epoch.

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20values%20%3E%20(items)%20%3E%20(property)%20expiration">Link to this property</a>

</details>

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20values">Link to this property</a>

</details>

<a href="#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%201">Link to this property</a>

</details>

[Link to this property](<#(resource)%20kv.namespaces%20%3E%20(model)%20namespace_bulk_get_response%20%3E%20(schema)>)

#### KVNamespacesKeys

##### [List keys in a namespace](https://developers.cloudflare.com/api/python/resources/kv/subresources/namespaces/subresources/keys/methods/list)

kv.namespaces.keys.list(strnamespace\_id, KeyListParams\*\*kwargs) -> SyncCursorLimitPagination\[[Key](<https://developers.cloudflare.com/api/python/resources/kv#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key%20%3E%20(schema)>)]

GET/accounts/{account\_id}/storage/kv/namespaces/{namespace\_id}/keys

##### [Write multiple key-value pairs](https://developers.cloudflare.com/api/python/resources/kv/subresources/namespaces/subresources/keys/methods/bulk_update)

Deprecated

kv.namespaces.keys.bulk\_update(strnamespace\_id, KeyBulkUpdateParams\*\*kwargs) -> [KeyBulkUpdateResponse](<https://developers.cloudflare.com/api/python/resources/kv#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_update_response%20%3E%20(schema)>)

PUT/accounts/{account\_id}/storage/kv/namespaces/{namespace\_id}/bulk

##### [Delete multiple key-value pairs](https://developers.cloudflare.com/api/python/resources/kv/subresources/namespaces/subresources/keys/methods/bulk_delete)

Deprecated

kv.namespaces.keys.bulk\_delete(strnamespace\_id, KeyBulkDeleteParams\*\*kwargs) -> [KeyBulkDeleteResponse](<https://developers.cloudflare.com/api/python/resources/kv#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_delete_response%20%3E%20(schema)>)

POST/accounts/{account\_id}/storage/kv/namespaces/{namespace\_id}/bulk/delete

##### [Get multiple key-value pairs](https://developers.cloudflare.com/api/python/resources/kv/subresources/namespaces/subresources/keys/methods/bulk_get)

Deprecated

kv.namespaces.keys.bulk\_get(strnamespace\_id, KeyBulkGetParams\*\*kwargs) -> [KeyBulkGetResponse](<https://developers.cloudflare.com/api/python/resources/kv#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_get_response%20%3E%20(schema)>)

POST/accounts/{account\_id}/storage/kv/namespaces/{namespace\_id}/bulk/get

##### ModelsExpand Collapse

<details>

<summary>

class Key: …

A name for a value. A value stored under a given key may be retrieved via the same key.

</summary>

name: str

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.

maxLength512

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key%20%3E%20(schema)%20%3E%20(property)%20name">Link to this property</a>

expiration: Optional\[float]

The time, measured in number of seconds since the UNIX epoch, at which the key will expire. This property is omitted for keys that will not expire.

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key%20%3E%20(schema)%20%3E%20(property)%20expiration">Link to this property</a>

metadata: Optional\[object]

Arbitrary JSON that is associated with a key.

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key%20%3E%20(schema)%20%3E%20(property)%20metadata">Link to this property</a>

</details>

[Link to this property](<#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key%20%3E%20(schema)>)

<details>

<summary>

class KeyBulkUpdateResponse: …

</summary>

successful\_key\_count: Optional\[float]

Number of keys successfully written or deleted by the bulk operation.

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_update_response%20%3E%20(schema)%20%3E%20(property)%20successful_key_count">Link to this property</a>

unsuccessful\_keys: Optional\[List\[str]]

Names of keys that failed to be written or deleted. Retry the operation for these keys.

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_update_response%20%3E%20(schema)%20%3E%20(property)%20unsuccessful_keys">Link to this property</a>

</details>

[Link to this property](<#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_update_response%20%3E%20(schema)>)

<details>

<summary>

class KeyBulkDeleteResponse: …

</summary>

successful\_key\_count: Optional\[float]

Number of keys successfully written or deleted by the bulk operation.

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_delete_response%20%3E%20(schema)%20%3E%20(property)%20successful_key_count">Link to this property</a>

unsuccessful\_keys: Optional\[List\[str]]

Names of keys that failed to be written or deleted. Retry the operation for these keys.

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_delete_response%20%3E%20(schema)%20%3E%20(property)%20unsuccessful_keys">Link to this property</a>

</details>

[Link to this property](<#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_delete_response%20%3E%20(schema)>)

<details>

<summary>

Optional\[KeyBulkGetResponse]

</summary>

One of the following:

<details>

<summary>

class WorkersKVBulkGetResult: …

</summary>

<details>

<summary>

values: Optional\[Dict\[str, Union\[str, float, bool, Dict\[str, object]]]]

Requested keys are paired with their values in an object.

</summary>

One of the following:

str

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%200%20%3E%20(property)%20values%20%3E%20(items)%20%3E%20(variant)%200">Link to this property</a>

float

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%200%20%3E%20(property)%20values%20%3E%20(items)%20%3E%20(variant)%201">Link to this property</a>

bool

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%200%20%3E%20(property)%20values%20%3E%20(items)%20%3E%20(variant)%202">Link to this property</a>

Dict\[str, object]

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%200%20%3E%20(property)%20values%20%3E%20(items)%20%3E%20(variant)%203">Link to this property</a>

</details>

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%200%20%3E%20(property)%20values">Link to this property</a>

</details>

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%200">Link to this property</a>

<details>

<summary>

class WorkersKVBulkGetResultWithMetadata: …

</summary>

<details>

<summary>

values: Optional\[Dict\[str, Optional\[WorkersKVBulkGetResultWithMetadataValues]]]

Requested keys are paired with their values and metadata in an object.

</summary>

metadata: object

The metadata associated with the key.

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20values%20%3E%20(items)%20%3E%20(property)%20metadata">Link to this property</a>

value: object

The value associated with the key.

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20values%20%3E%20(items)%20%3E%20(property)%20value">Link to this property</a>

expiration: Optional\[float]

Expires the key at a certain time, measured in number of seconds since the UNIX epoch.

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20values%20%3E%20(items)%20%3E%20(property)%20expiration">Link to this property</a>

</details>

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20values">Link to this property</a>

</details>

<a href="#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_get_response%20%3E%20(schema)%20%3E%20(variant)%201">Link to this property</a>

</details>

[Link to this property](<#(resource)%20kv.namespaces.keys%20%3E%20(model)%20key_bulk_get_response%20%3E%20(schema)>)

#### KVNamespacesMetadata

##### [Get a key's metadata](https://developers.cloudflare.com/api/python/resources/kv/subresources/namespaces/subresources/metadata/methods/get)

kv.namespaces.metadata.get(strkey\_name, MetadataGetParams\*\*kwargs) -> object

GET/accounts/{account\_id}/storage/kv/namespaces/{namespace\_id}/metadata/{key\_name}

#### KVNamespacesValues

##### [Get a key's value](https://developers.cloudflare.com/api/python/resources/kv/subresources/namespaces/subresources/values/methods/get)

kv.namespaces.values.get(strkey\_name, ValueGetParams\*\*kwargs) -> BinaryResponseContent

GET/accounts/{account\_id}/storage/kv/namespaces/{namespace\_id}/values/{key\_name}

##### [Write a key-value pair with optional metadata](https://developers.cloudflare.com/api/python/resources/kv/subresources/namespaces/subresources/values/methods/update)

kv.namespaces.values.update(strkey\_name, ValueUpdateParams\*\*kwargs) -> [ValueUpdateResponse](<https://developers.cloudflare.com/api/python/resources/kv#(resource)%20kv.namespaces.values%20%3E%20(model)%20value_update_response%20%3E%20(schema)>)

PUT/accounts/{account\_id}/storage/kv/namespaces/{namespace\_id}/values/{key\_name}

##### [Delete a key-value pair](https://developers.cloudflare.com/api/python/resources/kv/subresources/namespaces/subresources/values/methods/delete)

kv.namespaces.values.delete(strkey\_name, ValueDeleteParams\*\*kwargs) -> [ValueDeleteResponse](<https://developers.cloudflare.com/api/python/resources/kv#(resource)%20kv.namespaces.values%20%3E%20(model)%20value_delete_response%20%3E%20(schema)>)

DELETE/accounts/{account\_id}/storage/kv/namespaces/{namespace\_id}/values/{key\_name}

##### ModelsExpand Collapse

class ValueUpdateResponse: …

[Link to this property](<#(resource)%20kv.namespaces.values%20%3E%20(model)%20value_update_response%20%3E%20(schema)>)

class ValueDeleteResponse: …

[Link to this property](<#(resource)%20kv.namespaces.values%20%3E%20(model)%20value_delete_response%20%3E%20(schema)>)