You can use the create campaign API endpoint to create the events.
The payload should contain:
- The starting segment or form definition (
lists
orforms
in the JSON) - Events temporary IDs starting with the keyword ‘new’, they will be replaced with real IDs when the campaign is created
- Correct references to parent events
- Nodes and connections settings in
canvasSettings
Here is an example payload POST /api/campaigns/new
:
{
"isPublished": true,
"name": "API Campaign",
"description": null,
"allowRestart": 0,
"events": [
{
"id": "new1",
"name": "Contact field value",
"type": "lead.field_value",
"eventType": "condition",
"order": 1,
"properties": {
"canvasSettings": {
"droppedX": "520",
"droppedY": "155"
},
"name": "",
"triggerMode": "immediate",
"triggerDate": null,
"triggerInterval": "1",
"triggerIntervalUnit": "d",
"triggerHour": "",
"triggerRestrictedStartHour": "",
"triggerRestrictedStopHour": "",
"anchor": "leadsource",
"properties": {
"field": "email",
"operator": "endsWith",
"value": "example.com"
},
"type": "lead.field_value",
"eventType": "condition",
"anchorEventType": "source",
"buttons": {
"save": ""
},
"field": "email",
"operator": "endsWith",
"value": "example.com"
},
"triggerDate": null,
"triggerInterval": 1,
"triggerIntervalUnit": "d",
"triggerHour": null,
"triggerRestrictedStartHour": null,
"triggerRestrictedStopHour": null,
"triggerRestrictedDaysOfWeek": [],
"triggerMode": "immediate",
"decisionPath": null,
"parent": null
},
{
"id": "new2",
"name": "Modify contact's tags",
"type": "lead.changetags",
"eventType": "action",
"order": 2,
"properties": {
"canvasSettings": {
"droppedX": "710",
"droppedY": "291"
},
"name": "",
"triggerMode": "immediate",
"triggerDate": null,
"triggerInterval": "1",
"triggerIntervalUnit": "d",
"triggerHour": "",
"triggerRestrictedStartHour": "",
"triggerRestrictedStopHour": "",
"anchor": "yes",
"properties": {
"add_tags": [
"2"
]
},
"type": "lead.changetags",
"eventType": "action",
"anchorEventType": "condition",
"buttons": {
"save": ""
},
"triggerRestrictedDaysOfWeek": [],
"add_tags": [
"example"
],
"remove_tags": []
},
"triggerDate": null,
"triggerInterval": 1,
"triggerIntervalUnit": "d",
"triggerHour": null,
"triggerRestrictedStartHour": null,
"triggerRestrictedStopHour": null,
"triggerRestrictedDaysOfWeek": [],
"triggerMode": "immediate",
"decisionPath": "yes",
"parent": {"id": "new1"}
}
],
"forms": [],
"lists": [
{
"createdByUser": "Admin User",
"modifiedByUser": null,
"id": 9,
"name": "Segment Test 1",
"publicName": "Segment Test 1",
"alias": "segment-test-1",
"description": null,
"category": null
}
],
"canvasSettings": {
"nodes": [
{
"id": "new1",
"positionX": "810",
"positionY": "186"
},
{
"id": "new2",
"positionX": "710",
"positionY": "291"
},
{
"id": "lists",
"positionX": "833",
"positionY": "50"
}
],
"connections": [
{
"sourceId": "lists",
"targetId": "new1",
"anchors": {
"source": "leadsource",
"target": "top"
}
},
{
"sourceId": "new1",
"targetId": "new2",
"anchors": {
"source": "yes",
"target": "top"
}
}
]
}
}