# Is the process instance id available as variable in the process instance?

**URL:** <https://forum.camunda.io/t/is-the-process-instance-id-available-as-variable-in-the-process-instance/45992>\
**Category:** Camunda 8 Topics\
**Created:** [June 28, 2023, 7:09pm UTC](https://forum.camunda.io/t/is-the-process-instance-id-available-as-variable-in-the-process-instance/45992 "2023-06-28T19:09:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jschulenklopper](https://forum.camunda.io/user_avatar/forum.camunda.io/jschulenklopper/32/25264_2.png) [@jschulenklopper](https://forum.camunda.io/u/jschulenklopper)\
**Post date:** [June 28, 2023, 7:09pm UTC](https://forum.camunda.io/t/is-the-process-instance-id-available-as-variable-in-the-process-instance/45992/1 "2023-06-28T19:09:51Z")

</div>

I have a simple flow, with as first step a REST API call to log some process instance attributes; I want to maintain an (external) log that a process has started.

Is the process instance id available as a variable in the process instance? I could not find this in the documentation or examples, and trying things like `processInstanceId` or `execution.processInstanceId` or `zeebe.process_instance_key` are not working.

On the other hand, I think (or hope) that such an attribute – just like: process instance start timestamp, process model id, process model version – is available from the process instance itself.

---

<div class="post-metadata">

**Author:** ![Ingo\_Richtsmeier](https://forum.camunda.io/user_avatar/forum.camunda.io/ingo_richtsmeier/32/25968_2.png) [@Ingo\_Richtsmeier](https://forum.camunda.io/u/Ingo_Richtsmeier)\
**Post date:** [June 29, 2023, 5:15pm UTC](https://forum.camunda.io/t/is-the-process-instance-id-available-as-variable-in-the-process-instance/45992/2 "2023-06-29T17:15:57Z")

</div>

Hi @jschulenklopper,

no, right now, the processInstanceKey is not available as a process variable automatically.

If you write your own worker, you can use `job.getProcessInstanceKey()` to access the processInstanceKey and save it to your variable.

Hope this helps, Ingo

---

<div class="post-metadata">

**Author:** ![jschulenklopper](https://forum.camunda.io/user_avatar/forum.camunda.io/jschulenklopper/32/25264_2.png) [@jschulenklopper](https://forum.camunda.io/u/jschulenklopper)\
**Post date:** [June 29, 2023, 10:17pm UTC](https://forum.camunda.io/t/is-the-process-instance-id-available-as-variable-in-the-process-instance/45992/3 "2023-06-29T22:17:56Z")

</div>

Thanks for the custom worker solution, and that the `job.getProcessInstanceKey()` is available there.

It’s unfortunate the variables are not available in the instance directly. I can think of cases where it’d be convenient that process instance variables (start time, process instance id, process definition id, process definition version, …) are available _in_ the process instance, for example to log some process data from the process towards an external system. Then the logged data can be correlated to the specific process and process execution.

The other solution that I can think of now is to include a logging service as a first process step, let it generate and return some data (including a random identifier that’ll act as a process instance key) that is made available as a variable in the process.

---

<div class="post-metadata">

**Author:** ![GotnOGuts](https://forum.camunda.io/letter_avatar_proxy/v4/letter/g/b77776/32.png) [@GotnOGuts](https://forum.camunda.io/u/GotnOGuts)\
**Post date:** [June 29, 2023, 10:36pm UTC](https://forum.camunda.io/t/is-the-process-instance-id-available-as-variable-in-the-process-instance/45992/4 "2023-06-29T22:36:39Z")

</div>

> [@jschulenklopper](#):
>
> I want to maintain an (external) log that a process has started.

If you’re working in C8, would an Exporter not work?

> **[Exporters | Camunda 8 Docs](https://docs.camunda.io/docs/self-managed/concepts/exporters/)**
>
> As Zeebe processes jobs and processes, or performs internal maintenance, it generates an ordered stream of records.

This way, you’re not loading the logging into the process itself, but into the overall execution environment.

(I think I probably missed something…)

---

<div class="post-metadata">

**Author:** ![Zelldon](https://forum.camunda.io/user_avatar/forum.camunda.io/zelldon/32/869_2.png) [@Zelldon](https://forum.camunda.io/u/Zelldon)\
**Post date:** [June 30, 2023, 5:26am UTC](https://forum.camunda.io/t/is-the-process-instance-id-available-as-variable-in-the-process-instance/45992/5 "2023-06-30T05:26:23Z")

</div>

I think this is related to [FEEL expressions for Camunda attributes / entities. · Issue #10987 · camunda/zeebe · GitHub](https://github.com/camunda/zeebe/issues/10987)

Maybe you can add your thoughts here so it can be considered in planning 🙂

Greets  
Chris
