verified
Create a JourneyCreate a Journey in the Journey Builder in Salesforce Marketing Cloud.
REST API
var endpoint = restInstanceUrl + "interaction/v1/interactions";
var payload = {
"key": GUID(),
"name": "My Journey",
"workflowApiVersion": 1.0,
"triggers": [],
"goals": [],
"activities": []
};
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";
request.postData = Stringify(payload);
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 endpoint = restInstanceUrl + "interaction/v1/interactions";
var payload = {
"key": GUID(),
"name": "My Journey",
"workflowApiVersion": 1.0,
"triggers": [],
"goals": [],
"activities": []
};
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";
request.postData = Stringify(payload);
var results = request.send();
var result = Platform.Function.ParseJSON(String(results.content));
Write(Stringify(result));
} catch(error) {
Write(Stringify(error));
}
</script>
{
"id": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
"key": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
"name": "My Journey",
"lastPublishedDate": "0001-01-01T00:00:00",
"version": 1,
"workflowApiVersion": 1,
"createdDate": "2023-05-14T19:00:00.000",
"modifiedDate": "2023-05-14T19:00:00.000",
"triggers": [],
"goals": [],
"exits": [],
"notifiers": [],
"entryMode": "NotSet",
"definitionType": "Multistep",
"defaults": {
"properties": {}
},
"metaData": {},
"executionMode": "Production",
"categoryId": 123456,
"status": "Draft",
"definitionId": "S0M3-GU1D-K3Y-G03SR1G4T-H3R3",
"scheduledStatus": "Draft"
}
Reference
Ressources and references related to the current methods.
Official documentation