Skip to main content

Demo workflow - how to use workflowStaticData()

Workflow preview

Workflow preview
100%
Demo workflow - how to use workflowStaticData() preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

This workflow demonstrates how to use the function to set any type of variable that will persist within workflow executions. [https://docs.n8n.io/code/cookbook/builtin/get workflow static data/](ht...

Best for

  • Engineering automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

n8n-nodes-base.webhook, n8n-nodes-base.noop, n8n-nodes-base.httprequest, n8n-nodes-base.code, n8n-nodes-base.scheduletrigger, n8n-nodes-base.stickynote, n8n-nodes-base.if

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Ria.

Original n8n.io source

1.1 Workflow description

Title
Demo workflow - how to use workflowStaticData()
Workflow name
Demo workflow - how to use workflowStaticData()

This workflow demonstrates how to use the workflowStaticData() function to set any type of variable that will persist within workflow executions.

https://docs.n8n.io/code/cookbook/builtin/get-workflow-static-data/

This can be useful for example when working with access tokens that expire after a certain time period. Using staticData we can keep a record of that access token and the expiry time and build our workflow logic around it.

Important

Static Data only persists across production executions, i.e. triggered by Webhooks or Schedule Triggers (not manual executions!) For this the workflow will have to be activated.

Setup

  • configure HTTP Request node to fetch access token from your API (optional)
  • activate workflow
  • test the workflow with the webhook production link
  • you can check the population of the static data in the single executions

Feedback

If you found this useful or want to report some missing information - I'd be happy to hear from you at [email protected]

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Webhook

Type / Role
n8n-nodes-base.webhook - webhook
Config choices
Version 2

Block 2 - continue with valid token

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 3 - get new accessToken

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 4 - 2. set token in static data

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 5 - Schedule Trigger

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 6 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 8 - if token is valid

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.2

Block 9 - 1. initiate static data

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

3. Summary Table

Workflow Demo workflow - how to use workflowStaticData()
Complexity intermediate
Nodes 9
Categories Engineering
Author Ria
Published 12 Nov 2024

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/2538/2538.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Demo workflow - how to use workflowStaticData() do?

This workflow demonstrates how to use the function to set any type of variable that will persist within workflow executions. [https://docs.n8n.io/code/cookbook/builtin/get workflow static data/](ht...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering use case.