Get contact portal id

Hi,

Is it possible to get the portal-id when using `/crm/v3/objects/contacts/search?hapikey=demo` ?

I can find any reference in https://developers.hubspot.com/docs/api/crm/contacts.

As an alternative, is it possible to return a permalink to the contact page?

Thanks

Hi @SycoLTH ,
You can use below curl for get portal id.
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => ‘https://api.hubapi.com/integrations/v1/me?hapikey=demo’,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => ‘’,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => ‘GET’,
CURLOPT_HTTPHEADER => array(
‘Cookie: __cfduid=d8707b68473db1e73feda0f9e7ec6c21e1611835199’
),
));
$response = curl_exec($curl);
$object =json_decode($response);
curl_close($curl);
return $object->portalId;
Hope this helps!
If we were able to answer your query, kindly help the community by marking it as a solution.
Thanks and Regards.

Thanks, but I don’t think that’s what I need.

I have this scenario:

  1. GET /integrations/v1/me?hapikey=demo and get portalId xxxxxxx
  2. use the same api key to search for a contact and get contactId
  3. redirect my user to /contacts/{xxxxxxx}/contact/{contactId}/

This is where things break, because my user is now redirected to a 404 page.

When he goes to the contacts list and opens the contact I see the browser pointed to /contacts/{yyyyyyy}/contact/{contactId}/

So how is it possible that the api key and the contact returned from a search have 2 different portalId values?

Where do I find the portalId of the contact?

Thanks

@SycoLTH

The API key is unique to the portal and once you have got the portal ID you will know for sure that the contacts you request with the same API key will belong to the same portal. You can not use your demo-portal-id to get an other portals customer ID - you must use the same API key for both cases.

So by first requesting the portal ID - and then requesting the Contact ID - you can build a permalink as you describe.