Create new tag via API

I’m looking at API docs, and can’t find a way to create a new tag using API. Checked both REST and XML-RPC, and it looks like I can only add existing tags to a contact using tag ID. Am I missing something? Is there a way to create a new tag, get it’s ID and then add to a contact?

Hi @Arseni_Timofeev, you can now create tags using the REST API! Here is the endpoint documentation that has more details. After creating a tag, you can then take the resulting id and use this endpoint to apply that tag to a contact.

As a two step process, you can also code to create a function to addTagWithDupCheckByName which I’ve found handy. Use the name to look up if the tag exists and if not create it. In either case you get the id back to use.

@John_Borelli @Nicholas_Trecina is there a way to get notified of new tags on a contact from the rest webhooks right now?

Yes, using the following events you can manage tag application notices:

“contactGroup.add”,
“contactGroup.applied”,
“contactGroup.delete”,
“contactGroup.edit”,
“contactGroup.removed”,

https://developer.infusionsoft.com/docs/rest/#!/REST_Hooks/list_hook_event_types

@Barney_admin_Kuntze The one you’re specifically looking for is contactGroup.applied which will fire when a tag is applied to a contact. If you want to watch for tags being removed from a contact, you’ll want to listen for contactGroup.removed.

2 Likes

@John_Borelli
Is there a way to pull a tag ID by its name. I’ve tried GET like this: https://api.infusionsoft.com/crm/rest/v1/tags/?name=test_api2_f025
But it’s just pulling all of my tags ignoring name in the query.

As a temporary fix, I’m pulling all tags within the category and then loop thru them to get the ID of a matching tag. I’m sure there should be a cleaner way.

Your link leads to an inactive developer message btw.

REST does not yet provide a way to list tags except by id. You can use the standard api with the same oauth2 access key that you would use for REST… using the data object you would want to query on the Group table using the GroupName field.

Thank you! That worked!
Here is what I did ( used XML-RPC along with php iSDK ):

$returnFields = array('Id');
$result = $this->ifs_app->dsFind('ContactGroup',1,0,'GroupName','test_api2_f025',$returnFields);
1 Like