Write State
Persists a value to the persistent state store.
Meant to store a value under key in the run (instance) or in the workflow key-value state (global, case). In the current runtime it always leaves through error with logger.debug is not a function, so nothing is written.
This operator allows workflows to remember information across different execution steps, or even share data between different workflows (using Global scope).
Scopes:
- Instance: Visible only to this workflow run.
- Case: Visible to all workflows in the same Case/Thread.
- Global: Visible system-wide (use with caution).
Use Cases:
- Saving a user's progress.
- Caching an API token.
- Passing data from a parent workflow to a child workflow via 'Case' scope.
How it works
- Merges the input item with the resolved config (config wins).
- Uses
scope(defaultinstance) and leaves througherrorwithMissing 'key'whenkeyis empty. - Calls
logger.debug(), which throws; the worker catches it and leaves througherror. The steps below are not reached today. global/case: returns{ value }onsuccessand asks the backend to save it under<key>orcase:<key>throughmeta.kv_state.instance: returns{ _state_update, value, port }, which the engine does not apply: the run variables do not change.
In a workflow
The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.
{
"node_id": "node-save-last-sync",
"label": "Save last sync time",
"operator_slug": "ops.state.write",
"operator_version": "1.0.0",
"config": {
"scope": "global",
"key": "last_sync_at",
"value": "{{ $now }}"
}
}{
"ok": false,
"port": "error",
"data": {
"port": "error",
"error": "logger.debug is not a function"
}
}Configuration
-
scopestring Required -
Visibility level of the stored variable.
Its configuration shows the shared execution settings, but this node does not apply retries (retryOnFail, maxTries) yet. continueOnFail is not applied by any node.
Behaviour in the code
What the implementation does with these keys beyond what the schema says.
-
key - Not in the config schema (only in the input contract), but read from the node config or, when unset there, from the input item:
key,value,ttl_ms. -
ttl_ms - Only logged; it is never applied.
Output ports
success default Not reached in the current runtime: the logger.debug() call fails first. Shown with the shape the code builds.
{
"value": "2026-11-26T15:04:05.000Z"
}error Every run today. The output is the whole returned object, { port, error }.
{
"port": "error",
"error": "logger.debug is not a function"
}In expressions
What a later node can read from this node's output with $("Write State").item.json.<path> (write your node's label instead of Write State). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through success, from the output shown in Ports.
| Expression | Editor | Worker |
|---|---|---|
$("Write State").item.json.valueThe stored value confirmation. |
Errors
| Message | Port | Cause and fix |
|---|---|---|
logger.debug is not a function | error | The worker calls logger.debug(), which the runtime logger does not provide. It happens on every run; there is no configuration that avoids it. |
Missing 'key' | error | key is set neither on the node nor in the input item. |
Input contract
-
keystring Required -
Variable Name/Key
-
valueany Optional -
Data to store (Any JSON serializable)
-
ttl_msnumber Optional -
Time-to-Live in milliseconds
Output contract
-
valueany Optional -
The stored value confirmation.
Contracts (JSON Schema)
The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.
{
"slug": "ops.state.write",
"name": "Write State",
"category": "ops",
"version": "1.0.0",
"description": "Persists a value to the persistent state store.\n\n This operator allows workflows to remember information across different execution steps, or even share data between different workflows (using Global scope).\n\n **Scopes:**\n - **Instance:** Visible only to this workflow run.\n - **Case:** Visible to all workflows in the same Case/Thread.\n - **Global:** Visible system-wide (use with caution).\n\n **Use Cases:**\n - Saving a user's progress.\n - Caching an API token.\n - Passing data from a parent workflow to a child workflow via 'Case' scope.",
"capabilities": [
"state",
"persistence",
"store"
],
"config_schema": {
"type": "object",
"required": [
"scope"
],
"properties": {
"scope": {
"type": "string",
"enum": [
"instance",
"case",
"global"
],
"default": "instance",
"title": "State Scope",
"description": "Visibility level of the stored variable."
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
}
},
"input_contract_schema": {
"type": "object",
"properties": {
"key": {
"type": "string",
"description": "Variable Name/Key"
},
"value": {
"type": "any",
"description": "Data to store (Any JSON serializable)"
},
"ttl_ms": {
"type": "number",
"description": "Time-to-Live in milliseconds"
}
},
"required": [
"key"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"value": {
"type": "any",
"description": "The stored value confirmation."
}
}
},
"ports": [
{
"port_id": "success",
"label": "Success",
"is_default": true,
"description": "State saved successfully."
},
{
"port_id": "error",
"label": "Error",
"description": "Database/Storage failure."
}
],
"execution_mode": "async",
"tags": [
"state",
"database",
"persistence"
],
"is_stateful": true,
"publisher": {
"identity": "org_link_loom",
"profile": {
"name": "Link Loom",
"verified": true,
"url": "https://me.veripass.com/link-loom",
"logo_url": null
}
}
}{
"type": "object",
"required": [
"scope"
],
"properties": {
"scope": {
"type": "string",
"enum": [
"instance",
"case",
"global"
],
"default": "instance",
"title": "State Scope",
"description": "Visibility level of the stored variable."
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
}
}{
"type": "object",
"properties": {
"key": {
"type": "string",
"description": "Variable Name/Key"
},
"value": {
"type": "any",
"description": "Data to store (Any JSON serializable)"
},
"ttl_ms": {
"type": "number",
"description": "Time-to-Live in milliseconds"
}
},
"required": [
"key"
]
}{
"type": "object",
"properties": {
"value": {
"type": "any",
"description": "The stored value confirmation."
}
}
}[
{
"port_id": "success",
"label": "Success",
"is_default": true,
"description": "State saved successfully."
},
{
"port_id": "error",
"label": "Error",
"description": "Database/Storage failure."
}
]Execution
- Execution
async- Stateful
- Yes
- Retries (
retryOnFail) - No
- Capabilities
statepersistencestore- Tags
statedatabasepersistence
Notes and limits
- The worker calls
logger.debug(), which the runtime logger does not provide (it offersinfo,warning,error,logandsuccess). The call throws on every run. - Key-value state lives in the workflow definition metadata (
kv_state), shared by every run of that workflow. The backend injects it at run start as$input.$kv_stateonly when the run uses the draft graph; runs of a published version receive none. Writes (meta.kv_stateof each step) are merged into the metadata after the run ends, so later nodes of the same run do not see them. There is no expiry. - To keep a value for later nodes of the same run, use the node output instead: downstream nodes read it with
{{ $json.<field> }}or by node name. - Leaving through
errordoes not fail the run: the engine follows the edges wired toerror, and if there are none the branch simply ends. - The
executionsettings (retryOnFail,maxTries,waitBetweenTries,continueOnFail,timeout_ms) are accepted, but neither this worker nor the engine applies them.
Reviewed against the orchestrator code · 31e874b · 2026-11-26