Answered

How to attach contacts to a new company? Unable to do so as the new company isn't accessible.

  • 18 August 2022
  • 3 replies
  • 93 views

Created a new company:

curl https://api.intercom.io/companies\
-X POST \
-H 'Authorization:Bearer <AuthToken>' \
-H 'Accept: application/json' \
-H 'Content-Type:application/json' -d '
{
"name": "Test Company",
"company_id": "18ac530",
}'

It was created successfully.

 

Then used the Intercom generated id for it to attach it to a contact:

$ curl https://api.intercom.io/contacts/62fe23da8c9c889b4c86b884/companies\
-X POST \
-H 'Authorization:Bearer <AuthToken>' \
-H 'Accept:application/json' -d '{
"id": <intercom_id for the company>
}'

Got an error, company not found.

 

The docs say that a company must have at least 1 user to be listed and accessible. But this is a Catch-22 how am I supposed to add users if I am unable to access the company.

 

To confirm, that my initial call to create the company was indeed successful, I ran this:

curl \
-s https://api.intercom.io/companies?company_id=18ac530\
-H 'Authorization:Bearer <AuthToken>' \
-H "Accept:application/json"

It was successful, so the company was indeed created it just isn't accessible because it doesn't have any users. How do I add users/contacts?

 

https://developers.intercom.com/intercom-api-reference/reference/company-model

 

icon

Best answer by Aparna 22 August 2022, 18:38

View original

3 replies

Hey @hasnain z​ You can attach users by sending Company information in the intercomSettings code snippet, as a JSON object called

company. You can also send Intercom company data with the REST API. Here is an article on that. You curl request should include the the unique identifier for the contact which is given by Intercom in the request path parameter and the unique identifier for the company which is given by Intercom

in the request body parameter

$ curl https://api.intercom.io/contacts/lt;id>/companies \
-X POST \
-H 'Authorization:Bearer <Your access token>' \
-H 'Accept:application/json' -d
 
{
"id": "56cde0cc3deab1bd8c000100"
}

 

Turns out there's an error in the docs. I got in touch with Intercom support and they said that they'll fix it. The curl command here (https://developers.intercom.com/intercom-api-reference/reference/attach-contact-to-company should have a header: "Content-Type: application/json" otherwise curl takes a default value that causes the "Company not found error".

I have the same error (not found) when trying to attach contact to company.

 

First I created the company and received 200 http status

POST -> event, status companies 200

Second I created the contact and received 200 http status

POST -> event, status contacts 200

Then I attached contact and got Not Found error

 

intercom-attach-user-error" data-fileid="0695c00000F4NylAAF 

In Intercom UI the contacts are registered besides companies aren't.

 

This is my user attach function code implementation wrote in Typescript. I pass contact id (id given by Intercom) in the url (red rectangle) and the company id (company_id) in body (blue rectangle).

intercom-attach-code" data-fileid="0695c00000F4NyRAAV 

 

Reply