Is there a way to add or remove tags per contact using Mautic API?
Yes. I use Make.com as api middleware to talk to Mautic all the time.
              
              
              1 Like
            
            
          Here is an example plain php call with basic auth:
$curl = curl_init();
// Set some options - we are passing in a user agent too here
  curl_setopt_array($curl, array(
  CURLOPT_RETURNTRANSFER => 1,
  CURLOPT_URL => "https://".$loginname.":".$password."@".$siteurl."/api/contacts/new",
  CURLOPT_USERAGENT => 'Mautic Connector',
  CURLOPT_POST => 1,
// posting the payload
  CURLOPT_POSTFIELDS => array(
    'firstname' => $firstname,
    'lastname' => $lastname,
    'email' => $email,
    'tags' => $tag
  )
));
curl_exec($curl);
You can remove tags by
In order to remove tag from contact add minus - before it. For example: tags: ['one', '-two'] - sending this in request body will add tag one and remove tag two from contact.
Source:
              
              
              2 Likes