Reference

Step KV (:kv)

Quick Answer

Use :kv for workspace-scoped key/value state that must survive across steps and runs.

{:type :kv :operation :get|:set|:delete|:exists|:increment|:append|:list-keys ...}

Canonical Shape

FieldTypeRequiredNotes
:typekeywordYesMust be :kv
:operationkeyword/stringYesOne of :get, :set, :delete, :exists, :increment, :append, :list-keys
:keystringDependsRequired for all key-based operations
:defaultanyNo:get fallback when key missing/expired
:valueanyNo:set payload
:ttlintNoTTL in seconds (1 to 31536000)
:metadatamapNoOptional metadata with :set
:if-not-existsboolNoConditional create on :set
:deltaint/doubleNoIncrement amount (:increment)
:item, :itemsany/vectorNoItems to append (:append)
:max-lengthintNoMax list size for :append (default 1000)
:prefixstringNoPrefix filter for :list-keys
:limitintNoMax keys for :list-keys

Limits And Behavior

  • Key length: max 256 chars.
  • Key charset: a-z, A-Z, 0-9, _, -, :.
  • Value size: max 1 MB serialized.
  • :ttl max: 31536000 seconds (1 year).
  • :list-keys limit max: 1000.
  • Expired keys are treated as missing during reads/exists/list.

Result Shapes

Representative results:

;; :get
{:success true :value {:foo "bar"} :exists? true}

;; :set
{:success true :key "session:123" :created? true}

;; :increment
{:success true :key "quota:user-42" :value 11 :previous 10}

;; :list-keys
{:success true :keys ["session:1" "session:2"] :count 2}

Canonical Example

{:functions [{:id :session-key
              :language :clojure
              :code "(fn [input]\n                       {:key (str \"session:\" (:session-id input) \":history\")})"}]
 :flow
 '(let [k (flow/step :function :build-session-key
             {:ref :session-key
              :input (flow/input)})
        history (flow/step :kv :load-history
                  {:operation :get
                   :key (:key k)
                   :default []})
        updated (conj history {:at (flow/now-ms)
                               :message \"hello\"})]
    (flow/step :kv :save-history
      {:operation :set
       :key (:key k)
       :value updated
       :ttl 86400}))}

Related

As of Feb 13, 2026