# Add or remove tags per contact via API?

**URL:** <https://forum.mautic.org/t/add-or-remove-tags-per-contact-via-api/26230>\
**Category:** General Discussion\
**Created:** [November 28, 2022, 8:24pm UTC](https://forum.mautic.org/t/add-or-remove-tags-per-contact-via-api/26230 "2022-11-28T20:24:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![techbill](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/techbill/32/8325_2.png) [@techbill](https://forum.mautic.org/u/techbill)\
**Post date:** [November 28, 2022, 8:24pm UTC](https://forum.mautic.org/t/add-or-remove-tags-per-contact-via-api/26230/1 "2022-11-28T20:24:31Z")

</div>

Is there a way to add or remove tags per contact using Mautic API?

---

<div class="post-metadata">

**Author:** ![patrickeidemiller](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/patrickeidemiller/32/511_2.png) [@patrickeidemiller](https://forum.mautic.org/u/patrickeidemiller)\
**Post date:** [November 29, 2022, 4:32am UTC](https://forum.mautic.org/t/add-or-remove-tags-per-contact-via-api/26230/2 "2022-11-29T04:32:01Z")

</div>

Yes. I use [Make.com](http://Make.com) as api middleware to talk to Mautic all the time.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [November 29, 2022, 7:46am UTC](https://forum.mautic.org/t/add-or-remove-tags-per-contact-via-api/26230/3 "2022-11-29T07:46:36Z")

</div>

Here is an example plain php call with basic auth:

```auto
$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:

> <https://github.com/mautic/mautic/issues/3907>
>
> What type of report is this:
> 
> | Q | A
> | ---| ---
> | Bug report? | 
> | Featur…e request? | x
> | Enhancement? | 
> 
> \## Description:
> When editing a contact's tags via the API it lets only adding new tags. It's better if it supports removing existing tags too.
