processInstanceId generation before starting instance

I am using Flowable 6.6.0 and Spring Boot 2.3.9

I would like to leverage processInstanceId in order to query the runtimeService or the historyService to check if a flow has completed or not.
My use case is as follow:

  1. The client sends a document to a controller in my spring boot application.
  2. The application gives back a unique id that identifies the process instance.
  3. The client polls for completion using this id (preferably processInstanceId)

However I start the process programmatically in a controller through processInstanceBuilder.start() before sending the response to the client.
Is there a way to generate an instanceId from within the controller and then passes this instanceID to the processInstanceBuilder?

Thanks for your help.

For this purpose, the businessKey concept was added. You can pass the business key on instance start and correlate through it later on.

Thank you very much Joram. That’s what I was looking for.