When you start a Workflow, you create an Instance. That Instance contains data stored in fields and tracks the status of your automation workflow. Each Step in your Workflow becomes a Step in your Instance.

The Instances client allows you to start and stop Instances, find and get data from your Instances and complete steps in your Instances. It provides the following methods:

getGets a specific Instance by Id
findSearch for Instances by Name or Owner
startStart an Instance of a Workflow
stopStop an Instance
getStepGet an Instance Step by ID
getStepsGet all Steps of an Instance
findStepsFind Steps across all Instances
completeStepComplete a Step

Quickstart Example


 * This example demonstrates finding a Workflow, starting an Instance of
 * that Workflow with some inputs, getting data from the Instance and
 * finally completing a Step in the Instance.

require_once(__DIR__ . '/vendor/autoload.php');

use Catalytic\SDK\CatalyticClient;
use Catalytic\SDK\Search\Where;

// Create and initialize the Catalytic SDK Client
$catalytic = new CatalyticClient();  

// Find workflows matching "Sdk Example Workflow"
$where = (new Where())->text()->matches("Sdk Example Workflow");

// `results` is a results page containing `workflows` and 
// a `nextPageToken` you can use to page through results.
$results = $catalytic->workflows()->find($where);

// Get the workflows from the $results
$workflows = $results->getWorkflows();

// If Workflows were found, get the first one
if ($workflows) {
	$workflow = $workflows[0]; 		
// If no Workflows were found, let's import one
else {
  $workflow = $catalytic->workflows()->import(new SplFileObject(""));

// Now that we've got our Workflow, let's start an Instance with inputs it expects
$instance = $catalytic->instances()->start(
  'SDK Example',
  'My first SDK example',
  array('Age' => 42, 'Name' => 'Alice')

// Find workflows matching "Sdk Example Workflow"
$where = (new Where)->text()->matches("Sdk Example Workflow");
$results = $catalytic->workflows()->find($where);

// Get the steps
$steps = $catalytic->instances->getSteps($instance->getId())->getSteps();

// Get the step we want to complete
$uploadStep = array_filter($steps, function ($value, $key) {
   return $key === 'name' && $value === "Upload Updated Spreadsheet and Set Email";
// Download the Data Table from the "Table" field as a CSV 
$tableId = $instance->getFields["Table"]->getValue();
$csvFile = $catalytic->dataTables()->download($tableId, 'csv');

// Do our "business logic" to transform the csv data
// As a simple example, we replace "Foo" with "Bar"
$updatedCsvContent = csvFile->OpenText()->ReadToEnd()->Replace("Foo", "Bar");

// Create the output csv file locally
$updatedCsvFile = new SplFileObject(sys_get_temp_dir(), 'w');


// To complete the step, we will set both a text and a file field
$stepRequest = $step
		->SetInput("Updated CSV", updatedCsvFile)
		->SetInput("Email Address", YourEmail);


echo "You should have an email waiting for you at $yourEmail now ", 
		 "with the updated CSV converted to an Excel attachment");