Last week we released a new version the ProcessMaker I/O workflow engine API which enhances the ProcessMaker I/O by opening up an additional endpoint to the API to let users work with process tokens. Let's look at how these process tokens work.
The findTokens API Endpoint
The ProcessMaker I/O engine creates a process token whenever a process instance starts. Tokens are used to manage the lifecycle of an instance. You can think of the token flow as the heartbeat of the engine. The new API endpoint uses the GET method and looks as follows: https://docs.api.processmaker.io/#operation/findTokens
How the Process Tokens Concept Works
To use this endpoint, you are going to be inputting a process ID and an instance ID. This is because process tokens are specific to each instance in a process. But what is a process token? Process Tokens essentially control the very concept of the "workflow" in a workflow engine. It is not possible to run the engine without tokens. Whenever the engine needs to process something, it issues tokens to compute what will happen in the next task of the workflow. To better understand token flow, imagine a chessboard. On a chessboard after each opponent has a turn, there is a unique configuration of the pieces on the board. Based on the configuration of the pieces on the board, we know all the possible next moves. Token flow works the same way. Look at the image below. At the start event, we know that the only possible token path is the sequence flow out of the start event. This is represented by "T1" in the sequence flow. Once the token reaches the first task, we know that there is still only one path outward from that task (still "T1"). However, when the token reaches the parallel gateway, there are two paths forward. So, at this gateway, something interesting happens. The initial token "T1" dies and gets exchanged for a 2 new tokens (T2 and T3). Since these 2 tokens are flowing out from the same parallel gateway, they will share the same token key. These tokens then die at the Parallel join and a fourth token is born - "T4."


