Upsert

Overview 

Updates a subscriber if one currently exists. If the subscriber does not exist, this function will add it.

Syntax 

Upsert(1)

Function Properties 

OrdinalTypeDescription
1stringRequired

Example 

This sample code updates the specified values for an existing subscriber or creates a new subscriber if necessary.

1var newSubscriber = {
2    "EmailAddress": "test.008@example.com",
3    "SubscriberKey": "20100730001",
4    "EmailTypePreference": "Text",
5    "Attributes":{"First Name": "test.008", "Last Name": "test.008" },
6    "Lists": {"Status": "Active", "ID": 12345, "Action": "Upsert"}
7};
8
9var subObj = Subscriber.Init("SubKey");
10var status = subObj.Upsert(newSubscriber);