Create campaign with conditions via API

Your software
My Mautic version is: 3.2.4
My PHP version is: 7.3.26
My Database type and version is:

Your problem
My problem is: I’m trying to create a campaign with multiple events and conditions via the API. I am able to create the different campaign events, but the resulting campaign does not link them together, so each event runs on each contact, regardless of whether conditions are met to run the event. (this is probably related to trying to assign an event child/parent when the ID for that child/parent is unknown?)

These errors are showing in the log: n/a

Steps I have tried to fix the problem:

  • Create a campaign in the UI structured how I want it. Retrieve that campaign’s data with a GET request and copy the entire data set into a POST request for a new campaign. This creates the events (and events even have the correct parents), but the children arrays are not populated and, if the campaign runs, the conditions are not applied.
  • Clone a campaign. This creates a campaign with no events at all.
  • Various iterations on adding child events via PATCH request once I know the ID of the parent, but I may not be doing this correctly
1 Like

It may be a bug if you just GET an existing campaign and use the same data to POST a new one. The connections should be the same. It needs some investigation in the Mautic’s code to see why is this happening.

Check this comment: Mautic api for campaign events - #6 by patryk.gruszka