Add a tag that is already on the contact?

I am using the PHP SDK to manipulate Keap contact records. (Not sure which version - how do I tell?) Here’s my scenario:

I have a specific contact record. I want to remove two tags from this contact if they exist, but at most one of them will exist, and it’s possible that neither exists. Question: Do I need to explicitly check for each tag before trying to remove it, or can I just call removeTags() on the contact record with the array of tags to remove?

1 Like

You DO NOT have to check if they exist. You CAN just remove them.

If I remember correctly, the response will return 0 or 1 if the action was successful. If The tag is NOT present it will return 0.

1 Like

You can safely call removeTags() with the array of tag IDs even if one or both tags aren’t currently assigned to the contact—it will quietly ignore any that don’t exist without causing an error, so there’s no need to check beforehand.