Postman is not allowing me to add a contact to a segment

I can add a new contact, and pull up contacts by ID however what i really need is to be able to add a contact to a segment… I am using the following…
{{MauticDomain}}/segments/addContact(9, 1791)
The 9 is the segmentid and 1791 is a contact id… any suggestions would be appreciated.
Thanks

If it helps any this is a Mautic setup on which the code is being run.

Hey @tommytx! Thanks for posting and welcome to the community! :trophy:

It’s hard to debug a ton without more info. But looking at the developer docs for the Mautic REST API, it looks like maybe you’re not making the correct API request. Here’s what I see from the docs for adding a contact to a segment:

POST /segments/SEGMENT_ID/contact/CONTACT_ID/add

So given the info you’ve laid out above, the request should be a POST request and look like this:
{{MauticDomain}}/segments/9/1791/add

Hope that helps!

1 Like

Thanks for taking the time to look… I really appreciate it… I am burned out i have spend weeks trying everything under the sun to get this to work and it sees to work ok on most of my commands but not this one… and its very important that I acheive this… your assist is greatly appreciated… I doubt this will help but below is a few commands that work well…
Works => GET {{MauticDomain}}/api/contacts?search=james chambers

Works => GET {{MauticDomain}}/api/contacts?search=Heidi

Works => POST {{MauticDomain}}/api/contacts/new
in body: email = myemail@me.com
firstname = Tommy
lastname = Tucker

Fails => POST {{MauticDomain}}/segments/9/1791/add
also tried in body segmentsid = 9
contactsid = 1791

1 Like

SOLVED: Thank you a million sean your are the best…
you got it sooooo close… that my experimenting pulled it thru to a winner…
Here is the final that worked…
WORKER => {{MauticDomain}}/api/segments/9/contact/1791/add

Not sure why but most of the commands they list in the developers documentation do not include the /api/ but it is needed as you see above to work on my machine…
I cannot thank you enough i been messing with this for weeks… maybe months since i put it aside for awhile…

1 Like

Hey @tommytx, glad it worked out for you!

One thing to note, Mautic does say that you need the /api/ in the docs. If you check out this part of the docs under “Endpoints”, it shows the base API endpoint including /api/ in the path. The base url and endpoints can be tricky though sometimes, I don’t blame you :slight_smile:

Happy API using!

1 Like