# Old API key as query string method is running

**URL:** <https://community.hubspot.com/t/old-api-key-as-query-string-method-is-running/70428>\
**Category:** APIs & Integrations\
**Tags:** php\
**Created:** [December 2, 2022, 10:45am UTC](https://community.hubspot.com/t/old-api-key-as-query-string-method-is-running/70428 "2022-12-02T10:45:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AMUKHERJEE1010](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@AMUKHERJEE1010](https://community.hubspot.com/u/AMUKHERJEE1010)\
**Post date:** [December 2, 2022, 10:45am UTC](https://community.hubspot.com/t/old-api-key-as-query-string-method-is-running/70428/1 "2022-12-02T10:45:06Z")

</div>

I have an API integration where using post method I am sending data to [https://api.hubapi.com/contacts/v1/contact/email/\<email\>/profile](https://community.hubspot.com/) api.  
Now I tried to send data to this API using POST menthod using new private app access token method in curl header. But is failed.  
But when I switch back to old [https://api.hubapi.com/contacts/v1/contact/email](https://api.hubapi.com/contacts/v1/contact/email/)\<email\>/profile?hapikey=\<api-key\> method then data gets synced as it was previously.  
Is it the right thing to do?

---

<div class="post-metadata">

**Author:** ![ChrisoKlepke](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/chrisoklepke/32/11213_2.png) [@ChrisoKlepke](https://community.hubspot.com/u/ChrisoKlepke)\
**Post date:** [December 2, 2022, 11:46am UTC](https://community.hubspot.com/t/old-api-key-as-query-string-method-is-running/70428/2 "2022-12-02T11:46:36Z")

</div>

Hey @AMUKHERJEE1010 ,

thank you for reaching out to the community.

I definitely recommend using the access token of a private app from now on. Even thought the API Key might still work for you now, I don’t expect it to work anytime soon.

Would you mind sharing with us what error message you get. You should get one in the console or maybe have look into the details of your logs within the Private App.

[Here is where you find these.](https://developers.hubspot.com/docs/api/private-apps#view-api-call-logs)

Cheers,

Chriso

---

<div class="post-metadata">

**Author:** ![coldrickjack](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/coldrickjack/32/6684_2.png) [@coldrickjack](https://community.hubspot.com/u/coldrickjack)\
**Post date:** [December 2, 2022, 11:48am UTC](https://community.hubspot.com/t/old-api-key-as-query-string-method-is-running/70428/3 "2022-12-02T11:48:35Z")

</div>

Hey @AMUKHERJEE1010,

As of November 30th HubSpot has [sunset the use of API keys](https://developers.hubspot.com/changelog/upcoming-api-key-sunset). I’m not sure why you are still able to make requests using one but I wouldn’t rely on this as a stable approach moving forward. You should be using the private app access token.

If your request is failing using an access token it’s likely that you’ve included it incorrectly. It should be passed as a header in the request. Are you getting any error messages/response codes back from HubSpot, if you are can you please share?

Also, I’d recommend using the newer [CRM Contact APIs](https://developers.hubspot.com/docs/api/crm/contacts) instead of the legacy v1 endpoints. Specifically the PATCH /crm/v3/objects/contacts/{contactId} endpoint. You can update contacts using email address as per the below:

 ![](https://d2qpr2jzcazej7.cloudfront.net/original/3X/3/5/35a491b02f5782e67ea8064dd27825bb35d1ce92.png)

---

<div class="post-metadata">

**Author:** ![AMUKHERJEE1010](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@AMUKHERJEE1010](https://community.hubspot.com/u/AMUKHERJEE1010)\
**Post date:** [December 2, 2022, 12:46pm UTC](https://community.hubspot.com/t/old-api-key-as-query-string-method-is-running/70428/4 "2022-12-02T12:46:13Z")

</div>

$headers = [  
‘Content-Type: application/json’,  
‘Authorization: Bearer \<access-token\>’,  
];

$url = ‘[https://api.hubapi.com/contacts/v1/contact/email/\](https://api.hubapi.com/contacts/v1/contact/email/%5C)/profile’;  
$arr = array(  
‘properties’ =\> array(  
array(  
‘property’ =\> ‘pls\_calculator\_annual\_results’,  
‘value’ =\> \<VALUE\>  
),  
array(  
‘property’ =\> ‘pls\_calculator\_fortnight\_results’,  
‘value’ =\> \<VALUE\>  
),  
array(  
‘property’ =\> ‘pls\_calculator\_payment\_years’,  
‘value’ =\> \<VALUE\>  
),  
array(  
‘property’ =\> ‘pls\_calculator\_equity\_remaining\_after\_20\_years’,  
‘value’ =\> \<VALUE\>  
)  
)  
);  
$post\_json = json\_encode($arr);

$ch = curl\_init();  
curl\_setopt($ch, CURLOPT\_HTTPHEADER, $headers);  
curl\_setopt($ch, CURLOPT\_POST, true);  
curl\_setopt($ch, CURLOPT\_POSTFIELDS, $post\_json);  
curl\_setopt($ch, CURLOPT\_URL, $url);  
curl\_setopt($ch, CURLOPT\_RETURNTRANSFER, true);  
$response = curl\_exec($ch);

$status\_code = curl\_getinfo($ch, CURLINFO\_HTTP\_CODE);  
$curl\_errors = curl\_error($ch);  
curl\_close($ch);

----- This was my code which didn’t work. That’s why I returned back to old API key as query string method

---

<div class="post-metadata">

**Author:** ![coldrickjack](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/coldrickjack/32/6684_2.png) [@coldrickjack](https://community.hubspot.com/u/coldrickjack)\
**Post date:** [December 2, 2022, 1:03pm UTC](https://community.hubspot.com/t/old-api-key-as-query-string-method-is-running/70428/5 "2022-12-02T13:03:50Z")

</div>

Hey @AMUKHERJEE1010 what error message (if any) are you getting back? Also make sure you’ve correctly assigned the crm.objects.contacts.write scope to your access token/private app.
