Skip to main content

Execution Status

Check whether a workflow execution has completed and retrieve its output data.

Base path: /process Auth: API Key (X-API-Key header) or JWT


Get Execution Status

GET /process/instance/{processInstanceId}

Returns the current status and all output variables for an execution.

Path parameters:

ParameterDescription
processInstanceIdThe instance ID returned when you started the execution

Response: 200 OK

{
"processInstanceId": "inst_xyz789",
"processId": "your-flow-uuid",
"processName": "Support Bot",
"processVersion": "3",
"stateCd": 1,
"startTime": "2026-02-20T10:00:00Z",
"endTime": "2026-02-20T10:00:12Z",
"correlationKey": "ticket-9981",
"data": {
"classification": "billing",
"responseText": "Your billing issue has been escalated..."
}
}

Execution status codes:

stateCdMeaning
0Running
1Completed
2Failed
3Cancelled

The data object contains all variables set during the execution — use this to get the flow's output.


Poll for Completion

Since executions are asynchronous, poll until stateCd is a terminal value:

async function waitForCompletion(instanceId, apiKey, intervalMs = 1000, timeoutMs = 60000) {
const start = Date.now();

while (Date.now() - start < timeoutMs) {
const res = await fetch(`/process/instance/${instanceId}`, {
headers: { 'X-API-Key': apiKey }
});
const instance = await res.json();

if (instance.stateCd === 1) return { success: true, data: instance.data };
if (instance.stateCd === 2) return { success: false, error: 'Execution failed' };
if (instance.stateCd === 3) return { success: false, error: 'Execution cancelled' };

await new Promise(r => setTimeout(r, intervalMs));
}

throw new Error(`Timed out after ${timeoutMs}ms`);
}

// Usage
const result = await waitForCompletion('inst_xyz789', 'apk_...');
console.log(result.data.responseText);