Delete an Automation verified

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

WSProxy

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

api.setClientId({
    "ID": Platform.Function.AuthenticatedMemberID(),
    "UserID": Platform.Function.AuthenticatedEmployeeID()
});

var customerKey = "S0M3-GU1D-K3Y-G03SR1G4T-H3R3";

var result = api.deleteItem("Automation", { 
    CustomerKey: customerKey
});
<script runat="server">

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

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

    api.setClientId({
        "ID": Platform.Function.AuthenticatedMemberID(),
        "UserID": Platform.Function.AuthenticatedEmployeeID()
    });
	
	try {

        var customerKey = "S0M3-GU1D-K3Y-G03SR1G4T-H3R3";

        var result = api.deleteItem("Automation", { 
            CustomerKey: customerKey
        });

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

</script>
{
    "Status": "OK",
    "RequestID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
    "Results": [
        {
            "Object": {
                "Schedule": null,
                "AutomationTasks": null,
                "IsActive": true,
                "AutomationSource": null,
                "Status": 0,
                "Notifications": null,
                "ScheduledTime": "0001-01-01T00:00:00.000",
                "AutomationType": null,
                "UpdateModified": false,
                "LastRunInstanceID": null,
                "CreatedBy": 0,
                "CategoryID": null,
                "LastRunTime": "0001-01-01T00:00:00.000",
                "LastSaveDate": "0001-01-01T00:00:00.000",
                "ModifiedBy": 0,
                "RecurrenceID": null,
                "LastSavedBy": 0,
                "InteractionObjectID": null,
                "Name": "",
                "Description": "",
                "Keyword": null,
                "Client": {
                    "ID": 100000000,
                    "ClientID1": 0,
                    "PartnerClientKey": null,
                    "UserID": 100000000,
                    "PartnerUserKey": null,
                    "CreatedBy": 0,
                    "ModifiedBy": 0,
                    "EnterpriseID": 0,
                    "CustomerKey": null,
                    "CustomerID": null
                },
                "PartnerKey": null,
                "PartnerProperties": [],
                "CreatedDate": "0001-01-01T00:00:00.000",
                "ModifiedDate": null,
                "ID": 0,
                "ObjectID": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
                "CustomerKey": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
                "Owner": null,
                "CorrelationID": null,
                "ObjectState": null,
                "IsPlatformObject": false
            },
            "StatusCode": "OK",
            "StatusMessage": "Program deleted",
            "OrdinalID": 0,
            "ErrorCode": 0,
            "RequestID": null,
            "ConversationID": null,
            "OverallStatusCode": null,
            "RequestType": "Synchronous",
            "ResultType": null,
            "ResultDetailXML": null
        }
    ]
}

WARNING

setClientId is required to avoid the "Delete Access is denied!" error.

Reference

Ressources and references related to the current methods.

Official documentation
SOAP object

Last Updated: