# Create campaign with conditions via API

**URL:** <https://forum.mautic.org/t/create-campaign-with-conditions-via-api/18047>\
**Category:** Product Support\
**Created:** [February 5, 2021, 12:35am UTC](https://forum.mautic.org/t/create-campaign-with-conditions-via-api/18047 "2021-02-05T00:35:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebehlmann](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ebehlmann/32/4151_2.png) [@ebehlmann](https://forum.mautic.org/u/ebehlmann)\
**Post date:** [February 5, 2021, 12:35am UTC](https://forum.mautic.org/t/create-campaign-with-conditions-via-api/18047/1 "2021-02-05T00:35:46Z")

</div>

**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

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [January 4, 2024, 11:09am UTC](https://forum.mautic.org/t/create-campaign-with-conditions-via-api/18047/2 "2024-01-04T11:09:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![patryk.gruszka](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/patryk.gruszka/32/9813_2.png) [@patryk.gruszka](https://forum.mautic.org/u/patryk.gruszka)\
**Post date:** [April 9, 2024, 9:46am UTC](https://forum.mautic.org/t/create-campaign-with-conditions-via-api/18047/3 "2024-04-09T09:46:09Z")

</div>

Check this comment: [Mautic api for campaign events - #6 by patryk.gruszka](https://forum.mautic.org/t/mautic-api-for-campaign-events/24098/6)
