Workers KV Namespace

Write multiple key-value pairs

Changed on

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.

put/storage/kv/namespaces/{namespace_id}/bulk

Request

  • Base URL: /cdn-cgi/local/explorer/api (relative, and the document was published on a file host, not at the API’s origin)
  • URL: /cdn-cgi/local/explorer/api/storage/kv/namespaces/{namespace_id}/bulk
  • Auth: none declared

Path parameters

namespace_idstring required

Namespace identifier tag.

Example:0f2ac74b498b48028cb68387c421e279

Request body

base64boolean

Indicates whether or not the server should base64 decode the value before storing it. Useful for writing values that wouldn't otherwise be valid JSON strings, such as images.

expirationnumber

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

expiration_ttlnumber

Expires the key after a number of seconds. Must be at least 60.

keystring required

A key's name. The name may be at most 512 bytes. All printable, non-whitespace characters are valid.

valuestring required

A UTF-8 encoded string to be stored, up to 25 MiB in length.

Example request

[
  {
    "expiration": 1578435000,
    "expiration_ttl": 300,
    "key": "My-Key",
    "metadata": {
      "someMetadataKey": "someMetadataValue"
    },
    "value": "Some string"
  }
]

Response

Write multiple key-value pairs response.

successtrue required

Whether the API call was successful.

Example response

{
  "errors": [],
  "messages": [],
  "success": true,
  "result": {
    "successful_key_count": 100
  }
}

Changes