Skip to main content
Track the status of async operations like collection creation, token minting, and contract deployment.

Methods

getWorkflowStatus()

Get the status and result of a Temporal workflow. Signature:
getWorkflowStatus(
  workflowId: string,
  requestOptions?: RequestOptions
): Promise<TemporalWorkflowStatusData>
Parameters:
ParameterTypeRequiredDescription
workflowIdstringYesTemporal workflow ID
Example:
const status = await client.temporal.getWorkflowStatus('workflow-id');

console.log('Status:', status.data.status);
console.log('Result:', status.data.result);

if (status.data.status === 'COMPLETED') {
  console.log('Workflow completed successfully!');
  console.log('Result:', status.data.result);
} else if (status.data.status === 'FAILED') {
  console.error('Workflow failed:', status.data.error);
}
Response:
{
  data: {
    status: 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED',
    result?: any,
    error?: string
  }
}

Workflow Status Values

  • RUNNING: Operation is in progress
  • COMPLETED: Operation completed successfully
  • FAILED: Operation failed (check error details)
  • CANCELLED: Operation was cancelled

Complete Example

import { OumlaSdkApiClient, OumlaSdkApiEnvironment } from '@oumla/sdk';

const client = new OumlaSdkApiClient({
  environment: OumlaSdkApiEnvironment.Sandbox,
  apiKey: 'your-api-key'
});

async function waitForWorkflow(workflowId: string) {
  let status;
  let attempts = 0;
  const maxAttempts = 60; // 2 minutes max (60 * 2 seconds)
  
  do {
    status = await client.temporal.getWorkflowStatus(workflowId);
    console.log(`Attempt ${attempts + 1}: Status = ${status.data.status}`);
    
    if (status.data.status === 'COMPLETED') {
      console.log('Workflow completed!', status.data.result);
      return status.data.result;
    }
    
    if (status.data.status === 'FAILED') {
      throw new Error(`Workflow failed: ${status.data.error}`);
    }
    
    if (status.data.status === 'CANCELLED') {
      throw new Error('Workflow was cancelled');
    }
    
    // Wait 2 seconds before checking again
    await new Promise(resolve => setTimeout(resolve, 2000));
    attempts++;
  } while (attempts < maxAttempts && status.data.status === 'RUNNING');
  
  if (status.data.status === 'RUNNING') {
    throw new Error('Workflow timeout - still running after max attempts');
  }
  
  return status.data.result;
}

// Usage
try {
  const result = await waitForWorkflow('workflow-id');
  console.log('Final result:', result);
} catch (error) {
  console.error('Error waiting for workflow:', error);
}
Polling Strategy: Implement exponential backoff for production applications to avoid excessive API calls while waiting for workflows to complete.