# Is it possible to return the processInstanceKey when starting an instance via API?

**URL:** <https://forum.camunda.io/t/is-it-possible-to-return-the-processinstancekey-when-starting-an-instance-via-api/51547>\
**Category:** Camunda 8 Topics\
**Tags:** process-engine, zeebe, web-modeler\
**Created:** [April 2, 2024, 3:29pm UTC](https://forum.camunda.io/t/is-it-possible-to-return-the-processinstancekey-when-starting-an-instance-via-api/51547 "2024-04-02T15:29:29Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Domingos\_Dias](https://forum.camunda.io/user_avatar/forum.camunda.io/domingos_dias/32/26761_2.png) [@Domingos\_Dias](https://forum.camunda.io/u/Domingos_Dias)\
**Post date:** [April 2, 2024, 3:29pm UTC](https://forum.camunda.io/t/is-it-possible-to-return-the-processinstancekey-when-starting-an-instance-via-api/51547/1 "2024-04-02T15:29:29Z")

</div>

Greetings everyone,

I’m using a webhook to start a process instance, I need to return the processInstanceKey after starting the instance, how can I do this?

 ![image](https://forum.camunda.io/uploads/default/original/3X/6/5/658fd09ec7936c035c2f794694888d962fc1733e.png)  
 ![image](https://forum.camunda.io/uploads/default/original/3X/e/3/e350119791a4f9ffcad84a7c2bf8e9f67b7d7720.png)

---

<div class="post-metadata">

**Author:** ![nathan.loding](https://forum.camunda.io/user_avatar/forum.camunda.io/nathan.loding/32/24171_2.png) [@nathan.loding](https://forum.camunda.io/u/nathan.loding)\
**Post date:** [April 2, 2024, 4:01pm UTC](https://forum.camunda.io/t/is-it-possible-to-return-the-processinstancekey-when-starting-an-instance-via-api/51547/2 "2024-04-02T16:01:45Z")

</div>

Hi @Domingos_Dias - have a look at the `correlation` variable that is available in the response expression:

 ![image](https://forum.camunda.io/uploads/default/original/3X/2/3/23042b5f4bf69ba9db8241b55470082536655de2.png)

> **[HTTP Webhook Connector | Camunda 8 Docs](https://docs.camunda.io/docs/components/connectors/protocol/http-webhook/#response-body-expression)**
>
> Start a process instance with your custom webhook configuration, triggered by an external HTTP call.

---

<div class="post-metadata">

**Author:** ![Domingos\_Dias](https://forum.camunda.io/user_avatar/forum.camunda.io/domingos_dias/32/26761_2.png) [@Domingos\_Dias](https://forum.camunda.io/u/Domingos_Dias)\
**Post date:** [April 2, 2024, 4:05pm UTC](https://forum.camunda.io/t/is-it-possible-to-return-the-processinstancekey-when-starting-an-instance-via-api/51547/3 "2024-04-02T16:05:32Z")

</div>

Hi @nathan.loding!  
Thanks for your response, but I don’t understand how passing the fixed value of the processInstanceKey can help in practice, the processInstanceKey is a dynamic value that can change under certain circumstances, so it is not practical to pass it statically in the response

---

<div class="post-metadata">

**Author:** ![nathan.loding](https://forum.camunda.io/user_avatar/forum.camunda.io/nathan.loding/32/24171_2.png) [@nathan.loding](https://forum.camunda.io/u/nathan.loding)\
**Post date:** [April 2, 2024, 6:45pm UTC](https://forum.camunda.io/t/is-it-possible-to-return-the-processinstancekey-when-starting-an-instance-via-api/51547/4 "2024-04-02T18:45:45Z")

</div>

@Domingos_Dias - the code blocks are examples of what the `correlation` variable contains; you aren’t setting it, the engine is. So for the start event example, you can set your response expression to something like:

```feel
={
  processInstanceKey: correlation.processInstanceKey,
  message: "Process started successfully"
}

```

---

<div class="post-metadata">

**Author:** ![Domingos\_Dias](https://forum.camunda.io/user_avatar/forum.camunda.io/domingos_dias/32/26761_2.png) [@Domingos\_Dias](https://forum.camunda.io/u/Domingos_Dias)\
**Post date:** [April 2, 2024, 8:17pm UTC](https://forum.camunda.io/t/is-it-possible-to-return-the-processinstancekey-when-starting-an-instance-via-api/51547/5 "2024-04-02T20:17:11Z")

</div>

> [@nathan.loding](#):
>
> `correlation.`

Thank you, that’s exactly what I was talking about

---

<div class="post-metadata">

**Author:** ![gevezex](https://forum.camunda.io/user_avatar/forum.camunda.io/gevezex/32/27804_2.png) [@gevezex](https://forum.camunda.io/u/gevezex)\
**Post date:** [April 2, 2024, 9:16pm UTC](https://forum.camunda.io/t/is-it-possible-to-return-the-processinstancekey-when-starting-an-instance-via-api/51547/6 "2024-04-02T21:16:06Z")

</div>

Why do I get this back:

```auto
{
  processInstanceKey: null,
  message: "Process started successfully"
}

```

---

<div class="post-metadata">

**Author:** ![Domingos\_Dias](https://forum.camunda.io/user_avatar/forum.camunda.io/domingos_dias/32/26761_2.png) [@Domingos\_Dias](https://forum.camunda.io/u/Domingos_Dias)\
**Post date:** [April 2, 2024, 9:23pm UTC](https://forum.camunda.io/t/is-it-possible-to-return-the-processinstancekey-when-starting-an-instance-via-api/51547/7 "2024-04-02T21:23:06Z")

</div>

I don’t understand what you mean

---

<div class="post-metadata">

**Author:** ![gevezex](https://forum.camunda.io/user_avatar/forum.camunda.io/gevezex/32/27804_2.png) [@gevezex](https://forum.camunda.io/u/gevezex)\
**Post date:** [April 2, 2024, 9:29pm UTC](https://forum.camunda.io/t/is-it-possible-to-return-the-processinstancekey-when-starting-an-instance-via-api/51547/8 "2024-04-02T21:29:12Z")

</div>

I did the same as you did, but my webhook message start even connector returns a null instead a processInstanceKey.  
My response body expression:

```auto
= { 
  processInstanceKey : correlation.processInstanceKey,
  message : "Process started successfully"
}

```

---

<div class="post-metadata">

**Author:** ![gevezex](https://forum.camunda.io/user_avatar/forum.camunda.io/gevezex/32/27804_2.png) [@gevezex](https://forum.camunda.io/u/gevezex)\
**Post date:** [April 2, 2024, 10:02pm UTC](https://forum.camunda.io/t/is-it-possible-to-return-the-processinstancekey-when-starting-an-instance-via-api/51547/9 "2024-04-02T22:02:03Z")

</div>

Ok found my problem, I needed to upgrade the webhook connectors to v10. I was using v8.  
Thnx for this important insight.

---

<div class="post-metadata">

**Author:** ![system](https://forum.camunda.io/uploads/default/original/3X/5/8/58d50142eacca605d35cb1ef9e6b86ae85f49436.png) [@system](https://forum.camunda.io/u/system)\
**Post date:** [April 9, 2024, 10:02pm UTC](https://forum.camunda.io/t/is-it-possible-to-return-the-processinstancekey-when-starting-an-instance-via-api/51547/10 "2024-04-09T22:02:08Z")

</div>

Closed on April 9, 2024, 10:02pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
