Create an Auto-Suppression List verified

Learn how to create an Auto-Suppression List in Salesforce Marketing Cloud (SFMC) with SSJS (server-side JavaScript). Code snippets include the WSProxy method.

Create an Auto-Suppression List for a Send Classification

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

var context = {
    Client: {
        ID: Platform.Recipient.GetAttributeValue("memberid")
    },
    Context: "BusinessUnit",
    SendClassificationType: "Marketing",
    AppliesToAllSends: false
};

var config = {
    Name: "MyNewSuppressionList",
    Category: 0,
    Description: "My Suppression List",
    Contexts: [
        context
    ]
};

var result = api.createItem("SuppressionListDefinition", config);
<script runat="server">

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

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

    try {

        var context = {
            Client: {
                ID: Platform.Recipient.GetAttributeValue("memberid")
            },
            Context: "BusinessUnit",
            SendClassificationType: "Marketing",
            AppliesToAllSends: false
        };

        var config = {
            Name: "MyNewSuppressionList",
            Category: 0,
            Description: "My Suppression List",
            Contexts: [
                context
            ]
        };

        var result = api.createItem("SuppressionListDefinition", config);

        Write(Stringify(result));

    } catch (error) {

        Write(Stringify(error));

    }

</script>
{
    "Status": "OK",
    "RequestID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
    "Results": [
        {
            "NewID": 0,
            "NewObjectID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
            "PartnerKey": null,
            "Object": {
                "Name": "MyNewSuppressionList",
                "Category": 0,
                "Description": "My Suppression List",
                "Contexts": [
                    {
                        "Context": "BusinessUnit",
                        "SendClassificationType": "Marketing",
                        "SendClassification": null,
                        "Send": null,
                        "Definition": null,
                        "AppliesToAllSends": false,
                        "SenderProfile": null,
                        "Client": null,
                        "PartnerKey": null,
                        "PartnerProperties": null,
                        "CreatedDate": "0001-01-01T00:00:00.000",
                        "ModifiedDate": null,
                        "ID": 0,
                        "ObjectID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
                        "CustomerKey": null,
                        "Owner": null,
                        "CorrelationID": null,
                        "ObjectState": null,
                        "IsPlatformObject": false
                    }
                ],
                "Fields": null,
                "SubscriberCount": 0,
                "NotifyEmail": null,
                "Client": null,
                "PartnerKey": null,
                "PartnerProperties": null,
                "CreatedDate": "0001-01-01T00:00:00.000",
                "ModifiedDate": null,
                "ID": 0,
                "ObjectID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
                "CustomerKey": null,
                "Owner": null,
                "CorrelationID": null,
                "ObjectState": null,
                "IsPlatformObject": false
            },
            "CreateResults": null,
            "ParentPropertyName": null,
            "StatusCode": "OK",
            "StatusMessage": "SuppressionListDefinition created",
            "OrdinalID": 0,
            "ErrorCode": 0,
            "RequestID": null,
            "ConversationID": null,
            "OverallStatusCode": null,
            "RequestType": "Synchronous",
            "ResultType": null,
            "ResultDetailXML": null
        }
    ]
}

Create an Auto-Suppression List for a Sender Profile

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

var context = {
    Client: {
        ID: Platform.Recipient.GetAttributeValue("memberid")
    },
    Context: "SenderProfile",
    SenderProfile: {
        ObjectID: "S0M3-GU1D-K3Y-G03SR1G4T-H3R3"
    },
    AppliesToAllSends: false
};

var config = {
    Name: "MyNewSuppressionList",
    Category: 0,
    Description: "My Suppression List",
    Contexts: [
        context
    ]
};

var result = api.createItem("SuppressionListDefinition", config);
<script runat="server">

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

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

    try {

        var request = api.retrieve("SenderProfile", ["Name", "ObjectID"], {
            Property: "Name",
            SimpleOperator: "equals",
            Value: "MySenderProfile"
        });

        var objId = request.Results[0].ObjectID;

        var context = {
            Client: {
                ID: Platform.Recipient.GetAttributeValue("memberid")
            },
            Context: "SenderProfile",
            SenderProfile: {
                ObjectID: objId
            },
            AppliesToAllSends: false
        };

        var config = {
            Name: "MyNewSuppressionList",
            Category: 0,
            Description: "My Suppression List",
            Contexts: [
                context
            ]
        };

        var result = api.createItem("SuppressionListDefinition", config);

        Write(Stringify(result));

    } catch (error) {

        Write(Stringify(error));

    }

</script>
{
    "Status": "OK",
    "RequestID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
    "Results": [
        {
            "NewID": 0,
            "NewObjectID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
            "PartnerKey": null,
            "Object": {
                "Name": "MyNewSuppressionList",
                "Category": 0,
                "Description": "My Suppression List",
                "Contexts": [
                    {
                        "Context": "SenderProfile",
                        "SendClassificationType": "Operational",
                        "SendClassification": null,
                        "Send": null,
                        "Definition": null,
                        "AppliesToAllSends": false,
                        "SenderProfile": null,
                        "Client": null,
                        "PartnerKey": null,
                        "PartnerProperties": null,
                        "CreatedDate": "0001-01-01T00:00:00.000",
                        "ModifiedDate": null,
                        "ID": 0,
                        "ObjectID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
                        "CustomerKey": null,
                        "Owner": null,
                        "CorrelationID": null,
                        "ObjectState": null,
                        "IsPlatformObject": false
                    }
                ],
                "Fields": null,
                "SubscriberCount": 0,
                "NotifyEmail": null,
                "Client": null,
                "PartnerKey": null,
                "PartnerProperties": null,
                "CreatedDate": "0001-01-01T00:00:00.000",
                "ModifiedDate": null,
                "ID": 0,
                "ObjectID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
                "CustomerKey": null,
                "Owner": null,
                "CorrelationID": null,
                "ObjectState": null,
                "IsPlatformObject": false
            },
            "CreateResults": null,
            "ParentPropertyName": null,
            "StatusCode": "OK",
            "StatusMessage": "SuppressionListDefinition created",
            "OrdinalID": 0,
            "ErrorCode": 0,
            "RequestID": null,
            "ConversationID": null,
            "OverallStatusCode": null,
            "RequestType": "Synchronous",
            "ResultType": null,
            "ResultDetailXML": null
        }
    ]
}

Reference

Ressources and references related to the current methods.

Official documentation
SOAP object

Last Updated: