Welcome to our newly overhauled Zephyr pages! See our new Overview, Examples, and Index.
Feedback is welcome at bottom of each page.


Makes an API user request.

api_user( object options [, string id ] )

This is for use only within a trigger custom zephyr script.

Make a user API Request

  • optionsA Key/Value Hash containing one or all items
    • keythe key type of id (see keys)
    • fieldsthe fields to return (see fields)
    • keysset some or all of the user keys (see keys)
    • keysconflictdefine behavior if keys conflict with existing keys (see keysconflict)
    • listskey/value hash; each key is the name of a list, and each value is 1 to subscribe the user from that list and 0 to remove the user from the list
    • varskey/value hash of replacement variables you want to set or a json string
    • optout_emailset email opt-out status to `none`, `all`, or `blast`
    • loginmark the user as logged in – pass site to represent a site login, app to represent an app login, and optionally user_agent and ip
  • idIf not set, Sailthru ID (SID) will be used

This function is basically a User API call in POST mode


api_user({"lists": {"listA": 1, "listB": 0}})

To set for a different email:

api_user({"lists": {"listA": 1, "listB": 0, "key": "email"}}, "joe@example.com")

Set Random Variable on Users for Future Cohort Testing

Use Case: Use in conjunction with Sailthru Trigger functionality to set a value between 0-9 on users upon receipt of a Welcome transactional. This allows you to pre-segment out your users immediately for down-the-line testing (ex. Exclude everyone with “welcome_segment = 0″ from the rest of the Welcome Series or a Reengagement Series as a testing benchmark). Used in conjunction with “random()”

Zephyr: {api_user({"vars": {"welcome_received": random(10)}})}

zephyr example welcome_received 3


This script uses the api_user() function to set a custom field (var called “welcome_received”) on a user upon receipt of a transactional template (in this scenario, a Welcome email). For user segmentation purposes, the script also uses random() to create a randomized value between 0-9 upon receiving this transactional. This is beneficial for future cohort testing as you’ll have pre-established user buckets.

Set Current Date/Time as User Profile Field Value

Use Case: Used in conjunction with the date() function, apply a date value to a user profile after they receive a “Subscription Cancellation” template in order to re-target down the line (ex. 30 days later, send an offer for 15% off if they resubscribe)


{api_user({"vars" : {"canceled_date" : date('yyyy-MM-dd', time("now"))}})}


zephyr example canceled_date


This script uses the api_user() function to set a custom field (called “canceled_date”) on a user upon receipt of a transactional template (in this scenario, a Cancellation Confirmation email). To generate the value, we use the time() function to produce the current timestamp and the date function to format it in the UNIX YYYY-MM-DD format, which is a requirement for storing a date value on the user profile. This can be beneficial for future retargeting, such as creating a daily Recurring Campaign with a Smart List of users whose “canceled_date” variable is exactly 30 days ago.