# Migrating from API Key to Private App with VIDs

**URL:** <https://community.hubspot.com/t/migrating-from-api-key-to-private-app-with-vids/66972>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [October 12, 2022, 4:04pm UTC](https://community.hubspot.com/t/migrating-from-api-key-to-private-app-with-vids/66972 "2022-10-12T16:04:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MJProvencher](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mjprovencher/32/81608_2.png) [@MJProvencher](https://community.hubspot.com/u/MJProvencher)\
**Post date:** [October 12, 2022, 4:04pm UTC](https://community.hubspot.com/t/migrating-from-api-key-to-private-app-with-vids/66972/1 "2022-10-12T16:04:50Z")

</div>

In our existing API Key setup, we have these URLs to determine if we need to do an ADD or an UPDATE based on a match on the **vid** :  
[https://api.hubapi.com/contacts/v1/contact/vid/XXXX/profile?hapikey=XXXX](https://api.hubapi.com/contacts/v1/contact/vid/XXXX/profile?hapikey=XXXX);  
How would I accomplish the same in the Private App setup, which references v3?  
[https://api.hubapi.com/crm/v3/objects/contacts](https://api.hubapi.com/crm/v3/objects/contacts)  
Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 13, 2022, 9:06am UTC](https://community.hubspot.com/t/migrating-from-api-key-to-private-app-with-vids/66972/2 "2022-10-13T09:06:25Z")

</div>

Hey [@](https://community.hubspot.com/t5/user/viewprofilepage/user-id/379041)[MJProvencher](https://community.hubspot.com/t5/user/viewprofilepage/user-id/460653)

Hey there it feels like you still need rely on V1

Still you can have a look at the below link - \>

[https://community.hubspot.com/t5/APIs-Integrations/API-for-contacts-v1-contact-vid-vid-profile-in-V3/m-p/413688](https://community.hubspot.com/t5/APIs-Integrations/API-for-contacts-v1-contact-vid-vid-profile-in-V3/m-p/413688)

**Regarding the migration →**

- **Go to you settings console on your hubspot account**
  - **Create a new private app for contacts**
    - **Define the scope** 

 ![ChehakWadhdwa_0-1665651927074.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/d/8/d805e1663dcd6ef6d7910aaa87520754c79e6266.png)

```
        Hope this helps!

        If we were able to answer your query, kindly help the community by marking it as a solution.

        Thanks and Regards.

```

---

<div class="post-metadata">

**Author:** ![MJProvencher](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mjprovencher/32/81608_2.png) [@MJProvencher](https://community.hubspot.com/u/MJProvencher)\
**Post date:** [October 13, 2022, 8:18pm UTC](https://community.hubspot.com/t/migrating-from-api-key-to-private-app-with-vids/66972/3 "2022-10-13T20:18:59Z")

</div>

Thanks for the reply—I think for developers more experienced, your response likely was a helpful solution.  
Let me try to simplify my noob question:  
Since I’m adding the access\_token to the header with `Authorization: Bearer`, can I simply remove the hapikey param from these existing links, turning this:

`$url = 'https://api.hubapi.com/contacts/v1/contact?hapikey=' . $api_key;`

into

`$url = 'https://api.hubapi.com/contacts/v1/contact';`

(in essence, leaving the rest of the implementation in place, since after passing the access\_token in the headers, that handles the authentication?)  
Again, sorry if these are super basic questions!

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 14, 2022, 6:18am UTC](https://community.hubspot.com/t/migrating-from-api-key-to-private-app-with-vids/66972/4 "2022-10-14T06:18:02Z")

</div>

Hey [@](https://community.hubspot.com/t5/user/viewprofilepage/user-id/379041)[MJProvencher](https://community.hubspot.com/t5/user/viewprofilepage/user-id/460653)

Yes, you can remove hapikey param from these existing links as these will be of no use from 1 December 2022 according to new privacy & policy changes of hubspot. All endpoints will rely on Private Apps that are the Authorization Bearer tokens.

Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regards.

---

<div class="post-metadata">

**Author:** ![MJProvencher](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/mjprovencher/32/81608_2.png) [@MJProvencher](https://community.hubspot.com/u/MJProvencher)\
**Post date:** [November 18, 2022, 7:13pm UTC](https://community.hubspot.com/t/migrating-from-api-key-to-private-app-with-vids/66972/5 "2022-11-18T19:13:02Z")

</div>

In case it helps, this is a summary of what I needed to do:

```lia-code-sample
define('HS_PRIVATE_APP_TOKEN', 'XXXXXX'); // added

$header = array(
	'Content-Type: application/json', // existing
	'Accept: application/json', // existing
	'Authorization: Bearer ' . HS_PRIVATE_APP_TOKEN // needed to be added everywhere
);

// removed the following:
// $url = 'https://api.hubapi.com/companies/v2/companies/paged?hapikey='.$api_key.$properties.'&limit=200'.$hs_offset;

// added this modified declaration, removing the $api_key param
$url = 'https://api.hubapi.com/companies/v2/companies/paged?limit=200'.$properties.$hs_offset;

// and this was existing as well
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);	

```
