REST Email Marketing API Documentation

Example 4 — Add to a workflow

Workflows in Symphonie can be triggered by many different conditions: polling from a segment, a new recipient added to the system, an open or click-through, adding to an Offline Event, or by explicitly adding a recipient using the API. This example demonstrates adding a recipient to an existing, known workflow. Workflows can be configured to allow a recipient to enter only one time, to allow multiple entries for the same recipient once the workflow has completed, or to allow the recipient to be in the workflow many times simultaneously. The API will report an error if the recipient cannot be inserted.

Adding a recipient to a workflow triggers the workflow to immediately begin processing the steps for that recipient.

private class wfRecipientAddStatus
	public System.Collections.Generic.List<string> notInDatabase = new System.Collections.Generic.List<string>();
	public System.Collections.Generic.List<string> duplicateInFile = new System.Collections.Generic.List<string>();
	public System.Collections.Generic.List<string> currentlyInWorkflow = new System.Collections.Generic.List<string>();
	public System.Collections.Generic.List<string> previouslyInWorkflow = new System.Collections.Generic.List<string>();

private static void RestExample4(System.Collections.Generic.List<string> emailAddresses)
		string url = "";

		System.Text.StringBuilder sb = new StringBuilder();

		sb.Append("{'accountName':'acme', 'login':'ApiUser', 'password':'dfbdsf7udf5dfg78dfs', 'workflowName':'API Add Test','emailAddresses':[");

		sb.AppendFormat("'{0}'", emailAddresses[0]);

		for (int loop = 1; loop < emailAddresses.Count; loop++)
			sb.AppendFormat(", '{0}'", emailAddresses[loop]);


		System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
		request.Method = "POST";
		request.ContentType = "application/json";
		request.ContentLength = sb.Length;
		using (Stream webStream = request.GetRequestStream())
			using (StreamWriter requestWriter = new StreamWriter(webStream, System.Text.Encoding.ASCII))

		string results;

		using (System.Net.WebResponse webResponse = request.GetResponse())
			using (Stream webStream = webResponse.GetResponseStream())
				using (StreamReader responseReader = new StreamReader(webStream))
					results = responseReader.ReadToEnd();

		if (results[0] == '[')
			System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
			wfRecipientAddStatus rd = jss.Deserialize<wfRecipientAddStatus>(results);

			foreach (string row in rd.notInDatabase)
				System.Console.WriteLine(row + " is not in the database");

			foreach (string row in rd.previouslyInWorkflow)
				System.Console.WriteLine(row + " has already been in the workflow");

			foreach (string row in rd.duplicateInFile)
				System.Console.WriteLine(row + " was duplicated in the input");
	catch ( System.Exception e )

# encoding: utf-8
require 'rest-client'
require 'json'

emails = ["","","Pdhhdffgd", ""]

url = ""
data = {"accountName":"acme", "login":"ApiUser", "password":"sfgdfgh45wthbf", "workflowName":"API Add Test",

data["emailAddresses"] = emails

resp = url, data.to_json, {"Content-Type": "application/json"}
if resp.code != 200
    puts "Add to workflow failed!"
    puts resp.code

if resp.body[0] == "{"
    data = JSON.parse resp.body
    for row in data["notInDatabase"]
        puts row + " in not in the database"
    for row in data["previouslyInWorkflow"]
        puts row + " has already been in the workflow"
    for row in data["duplicateInFile"]
        puts row + " was duplicated in the input"
    puts resp.text
import requests
import json

def workflows(emails = []):
    url = ""
    data = {"accountName":"acmew", "login":"ApiUser", "password":"xdhw6w7ehd56wg", "workflowName":"API Add Test",
    data["emailAddresses"] += emails

    resp =, json=data, headers={"Content-Type": "application/json"})
    if resp.status_code != 200:
        print "Add to workflow failed!"
        print resp.status_code
    if resp.text[0] == "[":
        data = json.loads(resp.text)
        for row in data["notInDatabase"]:
            print row + " is not in the database"
        for row in data["previouslyInWorkflow"]:
            print row + " has already been in the workflow"
        for row in data["duplicateInFile"]:
            print row + " was duplicated in the input"
        print resp.text

workflows(["","","Pdhhdffgd", ""])

Share this: