REST API - PHP SDK: Add tag to contact without loading contact

I am trying to add a tag to a contact using only IDs. I am using the official PHP SDK.

It appears that the SDK abstracts the REST API in a way that it is not possible to use the POST /contacts/{contactId}/tags endpoint without first fetching the entire contact record. This is less than ideal, as it doubles the amount of time it takes to add a tag and counts double towards the rate limit. If I already have the contact ID and the tag ID, is there a way to do this that I’m just not seeing? I am aware that the XML-RPC addToGroup() method does this, but I’d prefer to stick with the same REST classes that the rest of my application is using.


This worked for me:[contactId]/tags?access_token=[access token]

with a json packet of:

“tagIds”: [

See docs here:

Thanks John, but rolling my own API interface is even more work than just using the old XML-RPC methods in the SDK. I was hoping the official SDK had a method for this that I just wasn’t finding. The documentation is somewhat, er, lacking.

For instance, I can do this:
$infusionsoft->contacts('xml')->addToGroup($contactID, $tagID);

But I was hoping that the REST endpoints would be used in the SDK. All I could find was a method that takes a tag ID and applies it to the currently loaded contact, which requires fetching the contact by ID first. If I already have a contactID and a tagID, I don’t want to waste the time and API rate hit by fetching that entire contact record first just because the PHP SDK is incomplete in it’s implementation of the REST API.
I am thinking maybe I should add this myself. I am unfamiliar with the process of contributing to open source repos, but I’m happy to add to this when I have time if anyone could help me with the steps.

The SDK was extended from the XML-RPC design. It therefor has added support for making REST calls but doesn’t provide methods that correlate to every REST endpoint. I’m not sure how that equates to ‘rolling your own api interface’. It’s REST endpoints. There is no api interface, just calls to the endpoint. It works the same as any other REST api out there.

I haven’t tested this yet, but you might be able to try something like this:

$contact_service = $infusionsoft->contacts();
$contact_service->id = $your_contact_id;