# Can't seem to add any tags when creating a new contact

**URL:** <https://integration.keap.com/t/cant-seem-to-add-any-tags-when-creating-a-new-contact/16217>\
**Category:** API Q&A\
**Tags:** tags, api, php\
**Created:** [September 30, 2017, 10:56pm UTC](https://integration.keap.com/t/cant-seem-to-add-any-tags-when-creating-a-new-contact/16217 "2017-09-30T22:56:00Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jer\_Fortenberry](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@Jer\_Fortenberry](https://integration.keap.com/u/Jer_Fortenberry)\
**Post date:** [September 30, 2017, 10:56pm UTC](https://integration.keap.com/t/cant-seem-to-add-any-tags-when-creating-a-new-contact/16217/1 "2017-09-30T22:56:00Z")

</div>

I’ve been using the PHP SDK to interact with the API, and I have managed to successfully create contacts and include a couple of custom fields. I’m not trying to add a tag to the contacts as I create them so trigger a campaign. However, I have tried many different formats but with no success. The best thing I’ve been able to get so far is a message: “Tags can’t be added or removed through this object”.

I have created a new contact tag, which has an id of 103.

Here is a screenshot of the array from my request. Note: It works perfectly fine if I remove the tag\_ids.

 ![2017-09-30_15-56-59](https://us1.discourse-cdn.com/flex019/uploads/infusionsoft1/original/2X/a/ab0c19d20f92296fc51eea2017c21d8d717d2743.png)

So, how can I successfully add tags while creating a new contact? The field is there in the documentation, so I assume it’s possible.

Thanks,

---

<div class="post-metadata">

**Author:** ![John\_Borelli](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/john_borelli/32/11880_2.png) [@John\_Borelli](https://integration.keap.com/u/John_Borelli)\
**Post date:** [October 2, 2017, 7:38am UTC](https://integration.keap.com/t/cant-seem-to-add-any-tags-when-creating-a-new-contact/16217/2 "2017-10-02T07:38:46Z")

</div>

If you’re using the SDK with that request then you’ve got two different API’s mixed together. The SDK uses the PHP wrapper but does NOT involve JSON. The JSON record you’re showing is only used with the REST API.

---

<div class="post-metadata">

**Author:** ![Jer\_Fortenberry](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@Jer\_Fortenberry](https://integration.keap.com/u/Jer_Fortenberry)\
**Post date:** [October 2, 2017, 3:20pm UTC](https://integration.keap.com/t/cant-seem-to-add-any-tags-when-creating-a-new-contact/16217/3 "2017-10-02T15:20:13Z")

</div>

@John_Borelli - Can you help me understand this better? I thought I was using the REST API through the PHP SDK (as evidenced by my conversation with one of the developers in this ticket: [Call to undefined method Infusionsoft\Api\Rest\ContactService::add() · Issue #136 · infusionsoft/infusionsoft-php · GitHub](https://github.com/infusionsoft/infusionsoft-php/issues/136)).

Also, the screenshot I showed above is not JSON. It’s a PHP array I’m passing into the request.

---

<div class="post-metadata">

**Author:** ![John\_Borelli](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/john_borelli/32/11880_2.png) [@John\_Borelli](https://integration.keap.com/u/John_Borelli)\
**Post date:** [October 2, 2017, 3:24pm UTC](https://integration.keap.com/t/cant-seem-to-add-any-tags-when-creating-a-new-contact/16217/4 "2017-10-02T15:24:16Z")

</div>

Ok, so like most things…let’s try starting at the beginning. Post the source in question otherwise we’ll continue to get tripped up by words.

---

<div class="post-metadata">

**Author:** ![Jer\_Fortenberry](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@Jer\_Fortenberry](https://integration.keap.com/u/Jer_Fortenberry)\
**Post date:** [October 2, 2017, 3:42pm UTC](https://integration.keap.com/t/cant-seem-to-add-any-tags-when-creating-a-new-contact/16217/5 "2017-10-02T15:42:37Z")

</div>

@John_Borelli - Ok. Here’s the code. Assume that I’ve already setup my $infusionsoft object correctly - token is good, and that the fields I’m pulling from are valid data. I’ve already tested all of that and it’s correct. Again, it works completely fine if I just remove the tag\_ids from the array.

```
$contact = array(
			'email_addresses' => array(
				array(
					'email' => $data['preparer']['email'],
					'field' => 'EMAIL1'
				)
			),
			'given_name' => $data['preparer']['first_name'],
			'family_name' => $data['preparer']['last_name'],
			'company' => array(
				'company_name' => $data['preparer']['org_name']
			),
			'addresses' => array(
				array(
					'field' => 'BILLING',
					'line1' => $data['preparer']['mailing_street'],
					'line2' => $data['preparer']['mailing_second'],
					'locality' => $data['preparer']['mailing_city'],
					'postal_code' => $data['preparer']['mailing_zip'],
					'region' => "US-".$data['preparer']['mailing_st_abbr'],
					'country_code' => 'USA'
				)
			),
			'custom_fields' => array(
				array(
					'id' => 4, // 4 = Form Edit Url
					'content' => $data['edit_link']
				),
				array(
					'id' => 2, // 4 = Trustpilot review url
					'content' => $inviteUrl
				)
			),
			'tag_ids' => [103] // 'sendProductReview' contact tag
		);
		
		$infusionsoft->contacts()->create($contact);

```

---

<div class="post-metadata">

**Author:** ![Jer\_Fortenberry](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@Jer\_Fortenberry](https://integration.keap.com/u/Jer_Fortenberry)\
**Post date:** [October 2, 2017, 3:44pm UTC](https://integration.keap.com/t/cant-seem-to-add-any-tags-when-creating-a-new-contact/16217/6 "2017-10-02T15:44:47Z")

</div>

Also, I’ve tried all of the following formats for tag\_ids, and none of worked:

```
'tag_ids' => [103]

'tag_ids' => array(103)

'tag_ids' => array(array(103))

'tag_ids' => 103

```

---

<div class="post-metadata">

**Author:** ![Nicholas\_Trecina](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/nicholas_trecina/32/5338_2.png) [@Nicholas\_Trecina](https://integration.keap.com/u/Nicholas_Trecina)\
**Post date:** [October 2, 2017, 4:52pm UTC](https://integration.keap.com/t/cant-seem-to-add-any-tags-when-creating-a-new-contact/16217/7 "2017-10-02T16:52:44Z")

</div>

Hi @Jer_Fortenberry. I’m sorry for the confusion but tags cannot be applied when creating a new contact record, they must be applied as a separate API call. The `tag_ids` property that appears on the contact record is read only which is why you’re receiving the error message “Tags can’t be added or removed through this object”.

---

<div class="post-metadata">

**Author:** ![Jer\_Fortenberry](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@Jer\_Fortenberry](https://integration.keap.com/u/Jer_Fortenberry)\
**Post date:** [October 2, 2017, 5:03pm UTC](https://integration.keap.com/t/cant-seem-to-add-any-tags-when-creating-a-new-contact/16217/8 "2017-10-02T17:03:41Z")

</div>

@Nicholas_Trecina - Thank you for the more definitive info on this. Is there a reason that the API documentation doesn’t seem to make this clear? Is there a key to reading the documentation that I’m missing?

---

<div class="post-metadata">

**Author:** ![mike.christianson](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/mike.christianson/32/74_2.png) [@mike.christianson](https://integration.keap.com/u/mike.christianson)\
**Post date:** [October 2, 2017, 5:18pm UTC](https://integration.keap.com/t/cant-seem-to-add-any-tags-when-creating-a-new-contact/16217/9 "2017-10-02T17:18:25Z")

</div>

@Jer_Fortenberry @John_Borelli The PHP SDK uses both the XML-RPC and the REST APIs. For more detail see the [README.md](https://github.com/infusionsoft/infusionsoft-php/blob/master/README.md).

---

<div class="post-metadata">

**Author:** ![Nicholas\_Trecina](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/nicholas_trecina/32/5338_2.png) [@Nicholas\_Trecina](https://integration.keap.com/u/Nicholas_Trecina)\
**Post date:** [October 2, 2017, 6:01pm UTC](https://integration.keap.com/t/cant-seem-to-add-any-tags-when-creating-a-new-contact/16217/10 "2017-10-02T18:01:34Z")

</div>

@Jer_Fortenberry There isn’t a reason why the documentation can’t make this more clear. I will file a ticket for us to get this fixed.

---

<div class="post-metadata">

**Author:** ![Jer\_Fortenberry](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@Jer\_Fortenberry](https://integration.keap.com/u/Jer_Fortenberry)\
**Post date:** [October 2, 2017, 6:08pm UTC](https://integration.keap.com/t/cant-seem-to-add-any-tags-when-creating-a-new-contact/16217/11 "2017-10-02T18:08:13Z")

</div>

Thank you @Nicholas_Trecina

---

<div class="post-metadata">

**Author:** ![Christian\_Zagarskas](https://avatars.discourse-cdn.com/v4/letter/c/76d3ee/32.png) [@Christian\_Zagarskas](https://integration.keap.com/u/Christian_Zagarskas)\
**Post date:** [May 11, 2024, 9:15pm UTC](https://integration.keap.com/t/cant-seem-to-add-any-tags-when-creating-a-new-contact/16217/12 "2024-05-11T21:15:36Z")

</div>

Years later… human life is still being lost.

- time I will want back on my deathbed.
- time that needs to be explained to clients.
- time that turns into lost wages.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/infusionsoft1/original/2X/2/2aa501ab76584c13898224ae5a7f2e349ac2f041.png)

---

<div class="post-metadata">

**Author:** ![Marion\_Dorsett2](https://sea1.discourse-cdn.com/flex019/user_avatar/integration.keap.com/marion_dorsett2/32/14894_2.png) [@Marion\_Dorsett2](https://integration.keap.com/u/Marion_Dorsett2)\
**Post date:** [May 16, 2024, 2:29pm UTC](https://integration.keap.com/t/cant-seem-to-add-any-tags-when-creating-a-new-contact/16217/13 "2024-05-16T14:29:20Z")

</div>

It looks like the documentation has been updated now 😃
