# How to setup campaign for contacts added via API

**URL:** <https://forum.mautic.org/t/how-to-setup-campaign-for-contacts-added-via-api/6838>\
**Category:** General Discussion\
**Created:** [December 13, 2016, 9:35am UTC](https://forum.mautic.org/t/how-to-setup-campaign-for-contacts-added-via-api/6838 "2016-12-13T09:35:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![john](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@john](https://forum.mautic.org/u/john)\
**Post date:** [December 13, 2016, 9:35am UTC](https://forum.mautic.org/t/how-to-setup-campaign-for-contacts-added-via-api/6838/1 "2016-12-13T09:35:09Z")

</div>

Hi all!  
  
  
  
I will be adding contacts to my self hosted mautic site via the API.  
  
I want to start the timer to send an email sequence to new contacts but I’m a bit confused how to setup the campaign as I only see options for contacts added via forms.  
  
Do I need to add them to a specific segment or something too?  
  
  
  
Thanks  
  
  
  
John

---

<div class="post-metadata">

**Author:** ![john](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@john](https://forum.mautic.org/u/john)\
**Post date:** [December 13, 2016, 9:35am UTC](https://forum.mautic.org/t/how-to-setup-campaign-for-contacts-added-via-api/6838/2 "2016-12-13T09:35:09Z")

</div>

Hi all!

I will be adding contacts to my self hosted mautic site via the API.  
I want to start the timer to send an email sequence to new contacts but I’m a bit confused how to setup the campaign as I only see options for contacts added via forms.  
Do I need to add them to a specific segment or something too?

Thanks

John

---

<div class="post-metadata">

**Author:** ![MarkLL](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@MarkLL](https://forum.mautic.org/u/MarkLL)\
**Post date:** [December 14, 2016, 3:03pm UTC](https://forum.mautic.org/t/how-to-setup-campaign-for-contacts-added-via-api/6838/3 "2016-12-14T15:03:31Z")

</div>

Hi @john, adding to a segment would be my approach – with the Campaign based on the Segment.

After calling `$contactContext->create()` it returns an array that represents the contact. I used `$contact['contact']['id']` to retrieve the new contact ID, then call `$segmentContext->addContact($segmentId, $contactId);` or you could simply add a certain Tag and then apply a Filter to the segment based on that tag.
