# Error in API

**URL:** <https://community.hubspot.com/t/error-in-api/99823>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [February 9, 2024, 6:56am UTC](https://community.hubspot.com/t/error-in-api/99823 "2024-02-09T06:56:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PShastri](https://avatars.discourse-cdn.com/v4/letter/p/a9a28c/32.png) [@PShastri](https://community.hubspot.com/u/PShastri)\
**Post date:** [February 9, 2024, 6:56am UTC](https://community.hubspot.com/t/error-in-api/99823/1 "2024-02-09T06:56:47Z")

</div>

Hi,

I am using hubspot contact API on postman its working fine. But in php i am getting error. I am posting code and its response kidly let me know the solution.

**PHP CODE**

$curl = curl\_init();  
curl\_setopt\_array($curl, array(  
CURLOPT\_URL =\> ‘[https://api.hubapi.com/crm/v3/objects/contacts?limit=10&properties=firstname&hapikey=XYZ](https://api.hubapi.com/crm/v3/objects/contacts?limit=10&properties=firstname&hapikey=XYZ)’,  
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’,  
));  
$response = curl\_exec($curl);  
curl\_close($curl);  
$agents = json\_decode($response);  
echo ‘\<pre\>’; print\_r($agents); die(‘Hello-world’);  
**RESPONSE**

```auto
stdClass Object
(
 [status] => error
 [message] => This app hasn't been granted all required scopes to make this call. Read more about required scopes here: https://developers.hubspot.com/scopes.
 [correlationId] => xyz
 [errors] => Array
 (
 [0] => stdClass Object
 (
 [message] => One or more of the following scopes are required.
 [context] => stdClass Object
 (
 [requiredScopes] => Array
 (
 [0] => e-commerce
 [1] => tickets
 [2] => crm.objects.goals.read
 [3] => media_bridge.read
 [4] => crm.objects.custom.read
 [5] => crm.objects.custom.write
 )

 [requiredGranularScopes] => Array
 (
 [0] => crm.objects.contacts.write
 [1] => crm.objects.line_items.read
 [2] => crm.objects.line_items.write
 [3] => crm.objects.quotes.write
 [4] => crm.objects.quotes.read
 [5] => crm.objects.contacts.read
 [6] => crm.objects.companies.read
 [7] => crm.objects.deals.read
 [8] => crm.objects.deals.write
 [9] => crm.objects.companies.write
 )

 )

 )

 )

```

---

<div class="post-metadata">

**Author:** ![dsmarion](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dsmarion/32/7509_2.png) [@dsmarion](https://community.hubspot.com/u/dsmarion)\
**Post date:** [February 9, 2024, 4:29pm UTC](https://community.hubspot.com/t/error-in-api/99823/2 "2024-02-09T16:29:59Z")

</div>

API Keys have been deprecated because they allow super admin access which is bad. Create a private app in your account and you can set your granular required scopes and it will give you an access token to use in your programming.

> **[Legacy private apps - HubSpot docs](https://developers.hubspot.com/docs/apps/legacy-apps/private-apps/overview)**
>
> Learn how to create legacy private apps in HubSpot.
