Archive an Asset verified

Learn how to archive an asset (move to Recycle Bin) in the Content Builder in Salesforce Marketing Cloud (SFMC) with SSJS (server-side JavaScript). Code snippets include REST API methods.

Archive by Id

var id = "123456";

var endpoint = restInstanceUrl + "asset/v1/content/assets/" + id + "/archive";

var request = new Script.Util.HttpRequest(endpoint);
    request.emptyContentHandling = 0;
    request.retries = 2;
    request.continueOnError = true;
    request.setHeader("Authorization", "Bearer " + accessToken);
    request.method = "PATCH";
    request.contentType = "application/json";

var results = request.send();

var result = results.statusCode;
<script runat="server">

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

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

    var restInstanceUrl = "https://YOUR_SUBDOMAIN.rest.marketingcloudapis.com/",
        accessToken     = "YOUR_REST_API_TOKEN";
	
	try {

        var id = "123456";

        var endpoint = restInstanceUrl + "asset/v1/content/assets/" + id + "/archive";

        var request = new Script.Util.HttpRequest(endpoint);
            request.emptyContentHandling = 0;
            request.retries = 2;
            request.continueOnError = true;
            request.setHeader("Authorization", "Bearer " + accessToken);
            request.method = "PATCH";
            request.contentType = "application/json";

        var results = request.send();

        var result = results.statusCode;

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

        Write(Stringify(error));
        
    }	

</script>
200

Reference

Ressources and references related to the current methods.

Official documentation

Last Updated: