---
schema_version: "1"
id: d56e93a7ff900dcfdc91f891566ee354ec3d4dcd506792e0e52b99d1303d1bb2
title: Upsert
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/guides/mc-programmatic-content/ssjs_subscriberUpsert.md
canonical_url: https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/ssjs_subscriberUpsert.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 4e798c41c214a4fc4c861c749bc8a4adcb0c3d96a406cafb3753ef61d4768a5a
products:
  - Marketing Cloud Engagement APIs and Programmatic Languages
  - Marketing Cloud
---
# 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

<!--complex table-->

| Ordinal | Type   |              | Description |
| ------- | ------ | ------------ | ----------- |
| **1**   | string | **Required** |             |

## Example

This sample code updates the specified values for an existing subscriber or creates a new subscriber if necessary.

```
var newSubscriber = {
    "EmailAddress": "test.008@example.com",
    "SubscriberKey": "20100730001",
    "EmailTypePreference": "Text",
    "Attributes":{"First Name": "test.008", "Last Name": "test.008" },
    "Lists": {"Status": "Active", "ID": 12345, "Action": "Upsert"}
};

var subObj = Subscriber.Init("SubKey");
var status = subObj.Upsert(newSubscriber);
```
