NATS KV icon

NATS KV

Interact with NATS JetStream Key-Value Store - manage buckets and keys

Actions8

Overview

This node interacts with the NATS JetStream Key-Value (KV) store, allowing users to manage KV buckets and keys within those buckets. It supports operations such as creating, deleting, and retrieving bucket status, as well as managing individual keys by getting, putting, deleting, or viewing their history.

A common use case is when you want to store configuration data, user preferences, or cache information in a distributed KV store backed by NATS JetStream. For example, you might delete a specific key from a bucket that holds session data when a user logs out, ensuring stale sessions are removed.

In this context, the Delete operation on the Key resource removes a specified key from a given bucket.

Properties

Name Meaning
Bucket Name The name of the KV bucket to operate on. Must contain only letters, numbers, underscores, and hyphens (no spaces or dots). Example: user-preferences, app-config, cache-data.
Key The key to operate on within the bucket. Can use dots for hierarchical organization (e.g., user.123.settings). Cannot contain spaces. Example: config.database.host, user.profile.avatar, session.abc123.

Output

The output is an array of JSON objects corresponding to each input item processed. For the Delete Key operation, the output JSON typically contains the result of the deletion operation, which may include metadata about the deleted key or confirmation of success.

If an error occurs during processing, the output will include an error object describing the issue for the respective item.

No binary data output is produced by this operation.

Dependencies

  • Requires a valid connection to a NATS JetStream server with access to the KV store.
  • Needs an API authentication token or API key credential configured in n8n to establish the connection.
  • The node uses bundled NATS client libraries internally to communicate with the NATS server.

Troubleshooting

  • Invalid Bucket Name: Bucket names must only contain letters, numbers, underscores, and hyphens. Using spaces or dots will cause validation errors.
  • Unknown Resource or Operation: If the resource or operation parameter is incorrect or unsupported, the node will throw an error indicating the unknown resource or operation.
  • Connection Issues: Failure to connect to the NATS server due to invalid credentials or network issues will cause the node to error out.
  • Key Not Found: Attempting to delete a key that does not exist may result in an error or no-op depending on the underlying NATS KV behavior.
  • To resolve errors, verify bucket and key names, ensure correct credentials are set up, and confirm the NATS server is reachable.

Links and References

Discussion