Publish a Journey verified

Publish a Journey in the Journey Builder in Salesforce Marketing Cloud.

REST API

var journeyId = "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
    versionNumber = 1;

var endpoint = restInstanceUrl + "interaction/v1/interactions/publishAsync/";

    endpoint += journeyId + "?versionNumber=" + versionNumber;

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

var results = request.send();

var result = Platform.Function.ParseJSON(String(results.content));

Write(Stringify(result));
<script runat="server">

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

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

        var journeyId = "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
            versionNumber = 1;

        var endpoint = restInstanceUrl + "interaction/v1/interactions/publishAsync/";

            endpoint += journeyId + "?versionNumber=" + versionNumber;

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

        var results = request.send();

        var result = Platform.Function.ParseJSON(String(results.content));

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

</script>
{
    "statusId": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3"
}

WARNING

A Paused or Stopped Journey can't be published.

WARNING

This REST API is using an AsyncAPI method. This means that instead of returning a success message, the request returns the ID of its status.

Reference

Ressources and references related to the current methods.

Official documentation

Last Updated: