job Examples

Add Users to a New List

{"job":"update","report_email":"myemail@mydomain.com","query":{"source_list":"Main"},"update":{"lists":{"Main-copy":1}}}

This adds all the users on the list “Main” to a new list called “Main-copy.”

Add Users to a List using a URL File (in PHP)

$report_email = "reportemail@domain.com";
$url = "https://www.urlhere.com";
$client->processUpdateJobFromUrl($url, array("lists"=>array("listnamegoeshere"=>1)), $report_email ,  false)

Bulk Update the Optout Status of a List of Users

{'job':'update','query':{'source_list':'mylistname'},'update':{'optout':'all'}}

Query Users and Add That Segment to a New List

{"job":"update","report_email":"myemail@mydomain.com","query":{"source_list":"Main","criteria:["engagement_min"],"engagement":[5]},"update":{"lists":{"Main-copy":1}}}

This query checks for users on the list “Main” that have an engagement level of at least 5, and then adds those users to a new list called “Main-copy.”

Query Users on Multiple Lists and Add That Segment to a New List

{"job":"update","report_email":"myemail@mydomain.com","query":{"source_list":".multiple","multiple_source_list":["Main","Another List"],"criteria:["engagement_min"],"engagement":[5]},"update":{"lists":{"My Copy":1}}}

This query checks for users on the lists “Main” and “Another List” that have an engagement level of at least 5, and then adds those users to a new list called “My Copy.”

Query a Campaign and Add Those Users to a List

Example in PHP:

$sailthru->apiPost('job', array(
  'job' => 'blast_save_list',
  'blast_id' => '123456',
  'query' => array('criteria' => array('match'), 'field' => array('gender'), 'value' => array('male')),
  'list' => 'male list'
));

Example in JSON:

{"job":"blast_save_list","blast_id":"1234567","list":"My List","query":{"criteria":["valid"]}}

Set Custom Signup Date on a New/Existing Group of Users

Upload a CSV of new or existing users using the “import” parameter of the Job call, and set a custom signup date on these users. Note that the CSV must have two columns: emailand signup_date. Additionally, the “signup_dates” parameter must be passed in the call with a value of 1or true.

Example in PHP:

$api_client = new Sailthru_Client($client_api_key, $client_secret, $api_url);
$api_client.apiPost("job", array("job" => "import", "list" => "test_list", "signup_dates" => "true", "file" => "hello.csv"), array('file'));

Example in Ruby:

sc = Sailthru::SailthruClient.new("123456789101112131415","123456789101112131415","https://api.sailthru.com")
sc.api_post(:job, {"job"=>"import","list"=>"test2","signup_dates"=>true,"file"=>"hello.csv"}, "file")

Set Vars on a Group of Users

Find all users on the list Main who have an email address at sailthru.com and who open email more than 50% of the time in the state of NY. Add a var to those users called “is_sailthru” and set the value as true.

Example in JSON:

{"job":"update","report_email":"me@mydomain.com",
"query":{
   "source_list":"Main",
   "criteria":["domain","geo_state"],
   "value":["sailthru.com","NY US"],
   "geo_frequency":[null,50]
   },
"update":{"vars":{"is_sailthru":1}
   }
}

Third-Party Opt-out

You are working with a third party that is able to get you occasional exports of email addresses that need to be opted out on Sailthru.

Take the list of third party email addresses and turn them into a new line-separated list of emails, then put them on a private URL and:

$sailthru->apiPost('job', array(
  'job' => 'update',
  'url' => 'https://path/to/emails',
  'update' => array('optout' => 'blast'),
));

Or POST directly as a file:

$sailthru->apiPost('job', array(
  'job' => 'update',
  'update' => array('optout' => 'blast'),
), array(
  'file' => '/path/to/emails',
));

 

Other Examples

Populating Campaign With Per-User Data

You want to send a campaign which has a section showing how many new friends have joined the site per-user. You want to send the campaign as soon as possible after the data transfer is complete.

Create a JSON-format file with the users, setting a variable for each one, like so:

{"email":"foo@example.com","vars":{"new_friends":["Ian","Will","Praj","Eli","Emily"]}}
{"email":"bar@example.com","vars":{"new_friends":["Neil","John"]}}

Regular List Cleaning

You want to automatically remove disengaged users from your main  list and move them onto a disengaged  list. (You could achieve a similar effect by just using Smart Lists, but let’s assume for some reason you need to use normal lists.)

$sailthru->apiPost('job', array(
  'job' => 'update',
  'query' => array('source_list' => 'main',
                   'criteria' => array('engagement_max'),
                   'engagement' => array(2)),
  'update' => array('lists' => array('main' => 0, 'disengaged' => 1)),
));

 

Multiple Source Lists

You can query multiple lists at the same time. Use multiple source lists within the JOB call, ‘update’ type. For example:

("job",{"job"=>"update","report_email"=>"joe@example.com","query"=>{"source_list"=>".multiple", "multiple_source_list" => ["listname1","listname2"]}, "update"=>{"name of merged list" => 1}})
Top