# Access top-level workflow id and execution id in subworkflows - Custom Node or Code Node

**URL:** <https://community.n8n.io/t/access-top-level-workflow-id-and-execution-id-in-subworkflows-custom-node-or-code-node/98187>\
**Category:** Feature Requests\
**Tags:** node, workflow-building, custom-node\
**Created:** [April 7, 2025, 10:45pm UTC](https://community.n8n.io/t/access-top-level-workflow-id-and-execution-id-in-subworkflows-custom-node-or-code-node/98187 "2025-04-07T22:45:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pramsperger](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/pramsperger/32/69789_2.png) [@pramsperger](https://community.n8n.io/u/pramsperger)\
**Post date:** [April 7, 2025, 10:45pm UTC](https://community.n8n.io/t/access-top-level-workflow-id-and-execution-id-in-subworkflows-custom-node-or-code-node/98187/1 "2025-04-07T22:45:42Z")

</div>

## The idea is:

Expose the **top-level workflow ID** and **execution ID** in custom nodes and the Code node, even within sub-workflows. These values should be available as part of the execution context, regardless of whether the current node is running in the main workflow or within a sub-workflow.

## My use case:

We have a number of complex workflows that invoke sub-workflows to handle modular or reusable logic. For observability and audit purposes, we log key actions and outcomes to an external system. However, since each sub-workflow runs in its own execution context, it’s difficult to correlate actions across the parent-child workflow boundary.

Having access to the top-level workflow ID and execution ID from within sub-workflows would allow us to associate all logs and operations back to the original triggering workflow, providing full traceability and simplifying troubleshooting.

## I think it would be beneficial to add this because:

- It enables **end-to-end traceability** across nested workflows.
- It improves observability in **logging, error tracking, and auditing**.
- It allows developers to **implement custom logging and telemetry** without having to manually pass metadata between workflows.
- It aligns with common practices in distributed and event-driven systems where trace context is maintained across calls.

## Any resources to support this?

- Use cases in observability frameworks like [OpenTelemetry](https://opentelemetry.io/), which emphasize trace propagation across services.

## Are you willing to work on this?

Yes, other than working out the variable names, this is a very simple change to the Execute Workflow and Execute Workflow Trigger core nodes.

---

<div class="post-metadata">

**Author:** ![VitorGD](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/vitorgd/32/63218_2.png) [@VitorGD](https://community.n8n.io/u/VitorGD)\
**Post date:** [July 24, 2025, 6:58pm UTC](https://community.n8n.io/t/access-top-level-workflow-id-and-execution-id-in-subworkflows-custom-node-or-code-node/98187/2 "2025-07-24T18:58:59Z")

</div>

Just jumping in to say I’d really love to see this feature added — it would make a big difference for us and probably for a lot of other teams using n8n.

We have an auxiliary sub-workflow that handles service executions in parallel, and we need to avoid overlaps or too many concurrent runs. To manage that, we’ve built a locking mechanism that depends on the **parent execution ID and workflow ID**.

The issue is: we currently have to **manually pass these values** from the parent to every sub-workflow call. It works, but it’s easy to forget or misconfigure — especially when multiple people are maintaining the workflows.

If we could access something like `$parent.execution.id` or `$parent.workflow.id` directly inside the sub-workflow, it would:

- Make everything way more reliable
- Help with logging and debugging
- Improve traceability between workflows
- Reduce the chance of human error

Would be awesome to have this built-in.
