Cloudflare KV icon

Cloudflare KV

Store and retrieve data from Cloudflare Workers KV.

Overview

This node integrates with Cloudflare Workers KV, a globally distributed key-value storage system. It allows users to manage namespaces and store, retrieve, update, or delete key-value pairs within those namespaces.

The Set Multiple operation under the Key-Value resource enables setting multiple key-value pairs in bulk within a specified namespace. This is useful for batch updates or inserts, improving efficiency by reducing the number of API calls.

Practical examples:

  • Bulk updating configuration settings stored in KV.
  • Storing multiple user session tokens at once.
  • Uploading a batch of cached data entries for a web application.

Properties

Name Meaning
Namespace ID The identifier of the KV namespace where the key-value pairs will be stored.
Key-Value Pairs A collection of key-value pairs to set. Each pair includes:
  • Key: The key string to set.
  • Value: The value string to store.
  • Expiration (optional): Absolute expiration time as a UNIX timestamp (seconds since epoch). Must be greater than current time.
  • Metadata (optional): Arbitrary JSON metadata associated with the key-value pair. |

Output

The output is a JSON object representing the response from the Cloudflare KV API after attempting to set the multiple key-value pairs. Typically, this includes success status and any relevant details returned by the API.

Example structure:

{
  "success": true,
  "errors": [],
  "messages": []
}

If an error occurs, the output will contain error information describing what went wrong.

Dependencies

  • Requires a valid Cloudflare account with access to Workers KV.
  • Needs an API authentication token credential configured in n8n to authorize requests.
  • The node communicates with the Cloudflare API endpoint for KV namespaces and values.

Troubleshooting

  • Common issues:

    • Invalid or missing Namespace ID: Ensure the namespace exists and the ID is correct.
    • Expiration timestamps must be in the future; otherwise, the API may reject the request.
    • Metadata must be valid JSON; malformed JSON will cause errors.
    • API rate limits or permission issues can cause failures.
  • Error messages:

    • "Key not found": Returned when trying to get a key that does not exist.
    • HTTP 4xx or 5xx errors: Usually indicate authorization problems, invalid parameters, or server issues.
  • Resolution tips:

    • Verify credentials and permissions.
    • Check that all required fields are provided and correctly formatted.
    • Use absolute expiration times carefully and ensure they are valid UNIX timestamps.
    • Validate JSON metadata before submitting.

Links and References

Discussion