REST API: Create Contact: Company Name and Tags

I have managed to create a contact with the name, address, and e-mail information using Create Contact REST API, but struggling to add company name and tags to the contact.

Here is a sample request I am using:

{
  "given_name": "John",
  "family_name": "Smith",
  "job_title": "CEO",
  "company": {
    "company_name": "Test Pty Ltd"
  },
  "addresses": [
    {
      "field": "BILLING",
      "line1": "180 Main Road",
      "line2": null,
      "locality": "Sydney",
      "region": "AU-NSW",
      "postal_code": "2000",
      "country_code": "AUS"
    }
  ],
  "email_addresses": [
    {
      "email": "test@test.com",
      "field": "EMAIL1"
    }
  ],
  "tag_ids": null
}

The record gets created, but the company name is blank (I have two fields in InfusionSoft: one where I can type in the name, and one where I can look up the company name). Even if I update Company Name in InfusionSoft manually and retrieve the record via List Contact API, I still get “company”:null

I have read that the Company API is still in the works, so I am wondering what options are available to record the company name in the contact record.

A similar issue is with using tag_ids. If I populate the request above with “tag_ids”:[685] instead of null, the request returns (400) Bad Request. Similarly, if I add tags in InfusionSoft manually and retrieve the record via List Contact API, I get “tag_ids”:null. I suppose I can try Apply Tags API, but it would be great to be able to create the record in one request rather than two steps.

Thank you.

Hi @Anton_Loukine,

Thanks for reaching out for help. It seems our documentation needs a little work in order to be more clear. We’ll work to update that. In the meantime, I hope the following helps.

You may add Tags to a Contact using Apply Tags. See also Can't seem to add any tags when creating a new contact - #7 by Nicholas_Trecina.

However, you can associate a Contact with a Company in the Create a Contact call. The documentation is misleading: you should only specify the id of the Company.

"company": {
  "id": 13
}

Hi Mike,

Thank you for your response.

I am still struggling with creating a company record. I have read in other posts that the company API is still work in progress and the only “hack” available is creating a contact record and then updating to set Account ID to be equal to the Contact ID. There is no Account ID field in the REST documentation either. Every permutation I have tried results API returning Bad Request. I would appreciate an example of a sample JSON request that accomplishes this.

Also, I think rather than updating the documentation, it would be great to enhance the API to match the documentation. The new version of API is advertised as allowing for fewer requests, but this does not seem to be case. Rather than being able to create a contact with the company name and tags in one call, it appears that I need to make at least four calls or possibly even more. In addition to performance implications, this makes it also hard to roll things back should something fail in between.

Thank you.

Anton

Hi @Anton_Loukine,

Your best option for now would be to create a company record using XML-RPC. The company table is its own entity there so you don’t have to do any hacking in order to add one. See the Company section here for more details.

We are trying hard to keep our new API as RESTful as possible. Part of that includes modeling actionable things in the application (like tagging) as a RESTful resource. The addition of tag_ids on the contact model was a convenience for querying purposes, not for modification. Companies will also be considered a separate resource once they are implemented.

Thanks Nicholas. The XML-RPC doesn’t have the company API either, but I got it to work by creating a contact and then updating the AccountId as suggested somewhere on the forum.

The next dilemma is how to delete the company via the API? Calling delete contact with the company ID doesn’t work. Am I supposed to downgrade the company back into a contact to delete it?

Hi @Anton_Loukine, you’re correct that there is not a dedicated service for companies like there is for contacts in XML-RPC, but you can use DataService to access any of the supported tables.

Here’s an example request that will add a company:

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>DataService.add</methodName>
  <params>
    <param>
      <value>
        <string>{{privateKey}}</string>
      </value>
    </param>
    <param>
      <value>
        <string>Company</string>
      </value>
    </param>
    <param>
      <value>
        <struct>
          <member>
            <name>Company</name>
            <value>My Test Company</value>
          </member>
        </struct>
      </value>
    </param>
  </params>
</methodCall>

Here is an example request for deleting a company:

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>DataService.delete</methodName>
  <params>
    <param>
      <value>
        <string>{{privateKey}}</string>
      </value>
    </param>
    <param>
      <value>
        <string>Company</string>
      </value>
    </param>
    <param>
      <value>
        <string>3514</string>
      </value>
    </param>
  </params>
</methodCall>

Hope this helps!

Hi guys,

Thank you for the post and replies here. I got a related issue here on IS portal.

  • I have added company “id” to add/update contact REST API request, and it does link 2 elements together.
  • But on the IS portal, I got a text “No name” on the company hyperlink. The hyperlink works fine and it took me to corresponding company page. But the text on that hyperlink is so weird.

Please refer to screenshot for more details : IS_portal_company_issue

Here is the JSON I have used in contact add/edit request:

    {"company": {"id": 202401}}

Is that IS API issue or IS portal problem ? @Nicholas_Trecina @mike.christianson

Kind regards

So you know that the company that has the id 202401 already existed and if so, when you go to that record, does it show as having no name information?

The company with ID 202401 exists in portal. I can view it and it has correct name on it.

Please refer to this screenshot:

Additionally, I just found the quick search result is displaying the right Company name. Please refer to the screenshot below:

I guess the “IS portal” → Contact → General information has issue to show relabeled company field.

Do you recommend me to raise this issue to the separate forum post ?

Thank you looking into it.

So if you have a valid id and the company name is present then the company id isn’t assigned. There are two company fields on a contact. The companId field gets the id number and the company name can have just a text string. If the companyId is specified then, and only then, will the company name be filled in with the name information from that company record.

@Ming_Zhang Can you DM me your application name (https://{{appName}}.infusionsoft.com) so I can take a look? I did some testing myself and I was unable to duplicate a contact showing the company name as “No name” unless the company was added without a name.