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. Specifically for the Key - History operation, it retrieves the history of changes made to a specific key in a given bucket. This is useful for auditing, debugging, or tracking changes over time to configuration data, user preferences, or cached information stored in the KV store.

Practical examples:

  • Tracking all updates and deletions of a user's settings stored under a key like user.123.settings.
  • Auditing changes to application configuration values stored in a key such as config.database.host.
  • Debugging issues by reviewing the sequence of changes to session data keyed by session.abc123.

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 retrieve the history for. 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 JSON contains the history of the specified key within the bucket. This typically includes an array or list of historical entries representing each change event (such as put/update or delete) made to the key, along with metadata like timestamps and revision numbers.

The exact structure depends on the underlying NATS JetStream KV API but generally provides:

  • Revision number or version of each change.
  • Value stored at that revision (if applicable).
  • Metadata such as creation or modification timestamps.
  • Operation type (e.g., update, delete).

No binary data output is indicated for this operation.

Dependencies

  • Requires a connection to a NATS JetStream server with access to the KV store feature.
  • Needs an API authentication token or API key credential configured in n8n to establish the connection.
  • Uses the nats client library bundled internally for communication with the NATS server.
  • Node requires proper permissions to read from the specified KV bucket.

Troubleshooting

  • Invalid bucket name: Bucket names must only contain letters, numbers, underscores, and hyphens. Spaces or dots are not allowed. Ensure the bucket name follows these rules.
  • Unknown resource or operation errors: If the resource or operation parameter is incorrect or unsupported, the node will throw an error. Verify that "Key" is selected as the resource and "History" as the operation.
  • Connection failures: Errors connecting to the NATS server may occur if credentials are missing or invalid, or if the server is unreachable. Check network connectivity and credential configuration.
  • Key not found: If the specified key does not exist in the bucket, the history may be empty or an error might be returned depending on the server behavior.
  • Permission denied: Insufficient permissions on the NATS server for reading the KV bucket can cause errors. Confirm that the API key has appropriate rights.

Links and References

Discussion