You save your value on the database directly, as the concept of ‘state’ on API Workflow don’t exist. API workflow have no user (or login) needed. It’s like a standalone machine that execute operations without been log in, but perfect to send jobs in the background, not affecting any real user operations.
In my example I used a field LINE that increment +1 each time it run inside the LOOP. I have another condition that check if LINE is 10, and Terminate the process (action) at the Endpoint, like:
More info here:
When using states on a page, it can be ‘dangerous’ if you make some process on a list, and decide to quit the page… all states are erased. Same if you change the states during a process for other values.