Create a new List verified

Learn how to create a new List in Salesforce Marketing Cloud (SFMC) with SSJS (server-side JavaScript). Code snippets include Core and WSProxy methods.

Core

var config = {
    CustomerKey: GUID(),
    Name: "MyNewList",
    Description: "This is my new list"
}

var result = List.Add(config);
<script runat="server">

    Platform.Load("core", "1");

	try {

        var config = {
            CustomerKey: GUID(),
            Name: "MyNewOldList",
            Description: "This is my new list"
        }

        var result = List.Add(config);

        Write(Stringify(result));
		
	} catch(error) {

        Write(Stringify(error));
        
    }	

</script>
{
  "Remove": "function",
  "Update": "function",
  "Subscribers": {
    "parent": null,
    "Add": "function",
    "Retrieve": "function",
    "Update": "function",
    "Upsert": "function",
    "Unsubscribe": "function",
    "Tracking": {
      "Retrieve": "function"
    }
  }
}

WSProxy

var api = new Script.Util.WSProxy();

var subscribers = [
  {
      SubscriberKey: GUID(),
      EmailAddress: "example@mail.com",
      Status: "Active",
      EmailTypePreference: "HTML",
      Attributes: [
          {
              Name: "FirstName",
              Value: "John"
          },
          {
              Name: "LastName",
              Value: "Doe"
          }
      ]
  }
];

var result = api.createItem("List", {
    ListName: "MyNewList",
    Type: "Public",
    ListClassification: "PublicationList",
    Description: "This is my new list",
    Subscribers: subscribers
});
<script runat="server">

    Platform.Load("core", "1");

    var api = new Script.Util.WSProxy();

    try {

        var subscribers = [
            {
                SubscriberKey: GUID(),
                EmailAddress: "example@mail.com",
                Status: "Active",
                EmailTypePreference: "HTML",
                Attributes: [
                    {
                        Name: "FirstName",
                        Value: "John"
                    },
                    {
                        Name: "LastName",
                        Value: "Doe"
                    }
                ]
            }
        ];

        var result = api.createItem("List", {
            ListName: "MyNewList",
            Type: "Public",
            ListClassification: "PublicationList",
            Description: "This is my new list",
            Subscribers: subscribers
        });

        Write(Stringify(result));

    } catch (error) {

        Write(Stringify(error));

    }

</script>
{
    "Status": "OK",
    "RequestID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
    "Results": [
        {
            "NewID": 111111,
            "NewObjectID": null,
            "PartnerKey": null,
            "Object": {
                "ID": 222222,
                "CreatedDate": "0001-01-01T00:00:00.000",
                "ListName": "MyNewList",
                "Description": "This is my new list",
                "Type": "Public",
                "CustomerKey": null,
                "Category": 0,
                "Subscribers": [
                    {
                        "SubscriberKey": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
                        "Client": null,
                        "ID": 123456789,
                        "EmailAddress": "example@mail.com",
                        "Status": "Active",
                        "Attributes": [
                            null,
                            null
                        ],
                        "UnsubscribedDate": "0001-01-01T00:00:00.000",
                        "PartnerType": null,
                        "EmailTypePreference": "HTML",
                        "Lists": [
                            null
                        ],
                        "GlobalUnsubscribeCategory": null,
                        "SubscriberTypeDefinition": null,
                        "Addresses": null,
                        "PrimarySMSAddress": null,
                        "PrimarySMSPublicationStatus": "OptedIn",
                        "PrimaryEmailAddress": null,
                        "Locale": null,
                        "PartnerKey": null,
                        "PartnerProperties": null,
                        "CreatedDate": "0001-01-01T00:00:00.000",
                        "ModifiedDate": null,
                        "ObjectID": null,
                        "CustomerKey": null,
                        "Owner": null,
                        "CorrelationID": null,
                        "ObjectState": null,
                        "IsPlatformObject": false
                    }
                ],
                "ListClassification": "PublicationList",
                "AutomatedEmail": null,
                "OptInProfile": null,
                "SendClassification": null,
                "Client": null,
                "PartnerKey": null,
                "PartnerProperties": null,
                "ModifiedDate": null,
                "ObjectID": null,
                "Owner": null,
                "CorrelationID": null,
                "ObjectState": null,
                "IsPlatformObject": false
            },
            "CreateResults": null,
            "ParentPropertyName": null,
            "StatusCode": "OK",
            "StatusMessage": "Created List.",
            "OrdinalID": 0,
            "ErrorCode": 0,
            "RequestID": null,
            "ConversationID": null,
            "OverallStatusCode": null,
            "RequestType": "Synchronous",
            "ResultType": null,
            "ResultDetailXML": null
        }
    ]
}

Types and list classifications

Types

Here is the list of available types for creating a new List:

  • Public
  • Private
  • Salesforce
  • GlobalUnsubscribe
  • Master

List classifications

Here is the list of available list classifications for creating a new List:

  • ExactTargetList
  • PublicationList
  • SuppressionList

Reference

Ressources and references related to the current methods.

Official documentation
SOAP object

Last Updated: