# Custom Object Schema Creation

**URL:** <https://community.hubspot.com/t/custom-object-schema-creation/65836>\
**Category:** APIs & Integrations\
**Tags:** developer-tools\
**Created:** [September 25, 2022, 7:01pm UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836 "2022-09-25T19:01:31Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![MicoleDev](https://avatars.discourse-cdn.com/v4/letter/m/cdc98d/32.png) [@MicoleDev](https://community.hubspot.com/u/MicoleDev)\
**Post date:** [September 25, 2022, 7:01pm UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836/1 "2022-09-25T19:01:31Z")

</div>

Hi,

I am testing Hubspot CRM for future integration into our platform.

After I try to create a [custom object schema](https://developers.hubspot.com/docs/api/crm/crm-custom-objects) I get this exception error:  
Authentication credentials not found. This API supports both API Key and OAuth 2.0 authenti (truncated…)  
I dont understand the reason of not having access to it. When I go to the private app configuration I can see “crm.schemas.custom.write” in there.

![MicoleDev_1-1664132341241.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/d/3/d3865541487ecb1d41d7d03b3569adbd21d6c3df.png)

is this because I am using a demo account?

I can get access to every other endpoint.  
I find weird in the documentation schema creation only has API login as an authentication method

 ![MicoleDev_0-1664132795118.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/c/7/c70de64586d26b0ce77a31e11c2aaa9823ebafd5.png)

While every other endpoint allow us to use Oauth

 ![MicoleDev_1-1664132852259.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/d/3/d3bcf05aab3ddab22d3e2654f8c2e11dbbac1a1e.png)

I feel schema objects very interesting for the integration, and would be great to be tested before we start to implement Hubspot in our company.  
All the best

---

<div class="post-metadata">

**Author:** ![tominal](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tominal/32/73018_2.png) [@tominal](https://community.hubspot.com/u/tominal)\
**Post date:** [September 25, 2022, 10:55pm UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836/2 "2022-09-25T22:55:19Z")

</div>

I agree with you that this is weird.

There is a pilot that you have to request access to allowing you to use OAuth to create schemas. That is the only good solution that I can see at this moment.

API keys are being sunsetted, so I am not sure what is going to happen with schema creation…

Creating a schema with a private app key results in this error:

 ![tominal_0-1664146460398.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/2/8/2881b0d6a2923894a37a83d9ff4aaf34b04ad227.png)

Does anyone else have any ideas?

---

<div class="post-metadata">

**Author:** ![FHaard](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@FHaard](https://community.hubspot.com/u/FHaard)\
**Post date:** [September 28, 2022, 5:44pm UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836/3 "2022-09-28T17:44:33Z")

</div>

I don’t have any ideas but have the 'not available for public use’issue if using curl, and the “Authentication credentials not found” if I use the Python client library.

---

<div class="post-metadata">

**Author:** ![LeeBartelme](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/leebartelme/32/95647_2.png) [@LeeBartelme](https://community.hubspot.com/u/LeeBartelme)\
**Post date:** [September 27, 2022, 1:36pm UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836/4 "2022-09-27T13:36:49Z")

</div>

I have no problem creating a custom object using my private app token. Are you sure you have at least one enterprise hub (custom objects are limited to enterprise tiers) and you are using the private app token correctly (as a header)?

That being said the beta should be accessible in your portal to create custom objects from the UI. Navigate to the “Product Updates” link in the dropdown in the top right of your potal. If you click on “Betas” you should see one labeled “Manage and Visualize Your Data Model”. If you join that beta, you should be able to create custom objects from the portal settings.

 ![LeeBartelme_1-1664285994331.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/0/6/0653626c4c0a306bb08f0450265aa1bfe616d6ef.png)

 ![LeeBartelme_0-1664285956933.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/8/8a7d2ca9b646425dbc89672e1b58585d60a7b68b.png)

---

<div class="post-metadata">

**Author:** ![FHaard](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@FHaard](https://community.hubspot.com/u/FHaard)\
**Post date:** [October 7, 2022, 4:11pm UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836/5 "2022-10-07T16:11:47Z")

</div>

Hi,  
is there a reason that this would not work on trial enterprise accounts? It’s hard to evaluate if enterprise is worth it if a USP does not work in the trial, and it seems no schema interaction works using private apps on a trial enterprise account?

---

<div class="post-metadata">

**Author:** ![LeeBartelme](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/leebartelme/32/95647_2.png) [@LeeBartelme](https://community.hubspot.com/u/LeeBartelme)\
**Post date:** [October 7, 2022, 4:14pm UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836/6 "2022-10-07T16:14:53Z")

</div>

Can you share your code (with your Access Token removed) so we can see exactly what you are doing? I was able to create using the API and Access token using a trial enterprise hub.

---

<div class="post-metadata">

**Author:** ![FHaard](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@FHaard](https://community.hubspot.com/u/FHaard)\
**Post date:** [October 7, 2022, 4:41pm UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836/7 "2022-10-07T16:41:12Z")

</div>

This is the request

```lia-code-sample
from hubspot import HubSpot
import hubspot
from pprint import pprint
from hubspot.crm.schemas import ObjectSchemaEgg, ApiException

api_client = hubspot.Client.create(access_token=TOKEN)
labels = {
 "singular": "Test CO",
 "plural": "Test CO"
}
object_schema_egg = ObjectSchemaEgg(
 labels=labels,
 required_properties=["application_id", "status", "affiliate"],
 searchable_properties=["status"],
 primary_display_property="status",
 secondary_display_properties=[],
 properties=[{
 "name":"application_id",
 "label":"Application ID",
 "isPrimaryDisplayLabel": False},
 {
 "name":"status",
 "label":"Status",
 "isPrimaryDisplayLabel": True},
 {
 "name":"affiliate",
 "label":"Affiliate",
 "isPrimaryDisplayLabel": False}],
 associated_objects=["CONTACT"],
 name="testcustomschema")
try:
 api_response = api_client.crm.schemas.core_api.create(object_schema_egg=object_schema_egg)
 pprint(api_response)
except ApiException as e:
 print("Exception when calling core_api->create: %s\n" % e)

```

and the response is

```lia-code-sample
Exception when calling core_api->create: (401)
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'Date': 'Fri, 07 Oct 2022 16:36:21 GMT', 'Content-Type': 'application/json;charset=utf-8', 'Content-Length': '316', 'Connection': 'keep-alive', 'CF-Ray': '75680e1f483b9903-ARN', 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains; preload', 'Vary': 'origin, Accept-Encoding', 'CF-Cache-Status': 'DYNAMIC', 'Access-Control-Allow-Credentials': 'false', 'X-HubSpot-Auth-Failure': '401 Unauthorized', 'X-HubSpot-Correlation-Id': '4775757c-77a8-4b7c-934e-00e2310e68a4', 'Report-To': '{"endpoints":[{"url":"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=wXo1FpFtLOsOueMqu3zT2yVhdcW5StSUmVyUCRW16oRpyO4wCTSMVELyfdCQ8xy%2BjqIISf7kBKz4CcKsFIjpqvb7eIYZRk4nWYkrgxVT%2Bv7aUZpJvm6qWz4IExp3JMAT"}],"group":"cf-nel","max_age":604800}', 'NEL': '{"success_fraction":0.01,"report_to":"cf-nel","max_age":604800}', 'Server': 'cloudflare', 'alt-svc': 'h3=":443"; ma=86400, h3-29=":443"; ma=86400'})
HTTP response body: {"status":"error","message":"Authentication credentials not found. This API supports both API Key and OAuth 2.0 authentication and you can find more details at https://developers.hubspot.com/docs/methods/auth/oauth-overview","correlationId":"4775757c-77a8-4b7c-934e-00e2310e68a4","category":"INVALID_AUTHENTICATION"}

```

The same api client and token works for e.g. fetching custom objects if they’re created using the beta UI

---

<div class="post-metadata">

**Author:** ![LeeBartelme](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/leebartelme/32/95647_2.png) [@LeeBartelme](https://community.hubspot.com/u/LeeBartelme)\
**Post date:** [October 7, 2022, 5:13pm UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836/8 "2022-10-07T17:13:03Z")

</div>

Can you try doing it just from like Postman? Just trying to see maybe if it’s a client library thing? Also, I’m not familiar with Python at all. Just JS.

---

<div class="post-metadata">

**Author:** ![FHaard](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@FHaard](https://community.hubspot.com/u/FHaard)\
**Post date:** [October 7, 2022, 5:47pm UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836/9 "2022-10-07T17:47:06Z")

</div>

```lia-code-sample
curl --request POST \
 --url 'https://api.hubapi.com/crm/v3/schemas' \
 --header 'content-type: application/json' \
 --header 'authorization: Bearer $TOKEN' \
 --data '{
 "name": "my_object",
 "labels": {
 "singular": "My object",
 "plural": "My objects"
 },
 "primaryDisplayProperty": "my_object_property",
 "requiredProperties": [
 "my_object_property"
 ],
 "properties": [
 {
 "name": "my_object_property",
 "label": "My object property",
 "isPrimaryDisplayLabel": true
 }
 ],
 "associatedObjects": [
 "CONTACT"
 ],
 "metaType": "PORTAL_SPECIFIC"
 }'

{"status":"error","message":"The scope needed for this API call isn't available for public use. If you have questions, contact support or post in our developer forum.","correlationId":"96e40266-00fd-4597-9bff-94bc4a9bc079","links":{"support":"https://help.hubspot.com/","forum":"https://community.hubspot.com/t5/APIs-Integrations/bd-p/integrations"},"category":"MISSING_SCOPES"}⏎ 

```

The documentation at [Accounts Dashboard | HubSpot](https://developers.hubspot.com/docs/api/crm/crm-custom-objects) actually suggests HAPI key here, which are going away in a month or so.

---

<div class="post-metadata">

**Author:** ![LeeBartelme](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/leebartelme/32/95647_2.png) [@LeeBartelme](https://community.hubspot.com/u/LeeBartelme)\
**Post date:** [October 7, 2022, 5:49pm UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836/10 "2022-10-07T17:49:23Z")

</div>

I don’t know why on the example post request for the method they only list API Key. I’m just telling you it works in my own portal and a trial portal I have. I have postman setup and I’m not using API Keys and I’m able to create new custom objects just fine. They also list clearly the [migration information](https://developers.hubspot.com/docs/api/crm/crm-custom-objects#:~:text=Please%20note%3A%C2%A0starting,private%20app%20instead.) on that page. It is supposed to work with private apps.  
So I’m trying to isolate your issue to code or something else. If it works in Postman, we know it’s code related. If it doesn’t work in Postman, we know is’ account, configuration, token related.

---

<div class="post-metadata">

**Author:** ![FHaard](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@FHaard](https://community.hubspot.com/u/FHaard)\
**Post date:** [October 7, 2022, 6:03pm UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836/11 "2022-10-07T18:03:35Z")

</div>

I edited my reply to include curl commnad and output

---

<div class="post-metadata">

**Author:** ![LeeBartelme](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/leebartelme/32/95647_2.png) [@LeeBartelme](https://community.hubspot.com/u/LeeBartelme)\
**Post date:** [October 7, 2022, 6:29pm UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836/12 "2022-10-07T18:29:15Z")

</div>

So in that case I’m not sure I can help. Below is my curl generated from Postman. There must be something else going on with the private app permissions or something I don’t really know. The app I used had the following permissions.

![LeeBartelme_0-1665167256023.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/7/f/7ff7773db0abfcae06a4ecb21ff867ae6ab3453c.png)

It was a trial with marketing ent and sales ent trial. But either should get you custom objects (obviously since you can make them in the UI).

```lia-code-sample
curl --location --request POST 'https://api.hubapi.com/crm/v3/schemas' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer XXX' \
--data-raw '{
 "labels": {
 "singular": "Object",
 "plural": "Objects"
 },
 "name": "Object",
 "properties": [
 {
 "fieldType": "text",
 "label": "Prop",
 "name": "prop",
 "type": "string"
 }
 ],
 "primaryDisplayProperty": "prop"
}'

```

All I’d suggest at this point is to maybe create a new private app and grant it everything and just “see” if it works. I really don’t know. Based on what I can see, it should work.  
But as an aside, with the UI you really don’t need that API anyway. It’s no longer needed with it now being in the UI.

---

<div class="post-metadata">

**Author:** ![FHaard](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@FHaard](https://community.hubspot.com/u/FHaard)\
**Post date:** [October 8, 2022, 8:11am UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836/13 "2022-10-08T08:11:26Z")

</div>

I figured it out - the private app needs to be recreated after enterprise is activated, or you get these weird permission errors for some of the custom object endpoints (but not all).  
Thanks for your assistance!

---

<div class="post-metadata">

**Author:** ![LeeBartelme](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/leebartelme/32/95647_2.png) [@LeeBartelme](https://community.hubspot.com/u/LeeBartelme)\
**Post date:** [October 8, 2022, 2:10pm UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836/14 "2022-10-08T14:10:13Z")

</div>

Cool, in that case, I would think rotating the token might have worked as well. (Possibly not). It might be worth testing if you still have the old app running. If you do try rotating the token and it works, let me know. Rotating the token I would think, would refresh all those permissions behind the scenes.

---

<div class="post-metadata">

**Author:** ![FHaard](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@FHaard](https://community.hubspot.com/u/FHaard)\
**Post date:** [October 10, 2022, 3:41pm UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836/15 "2022-10-10T15:41:35Z")

</div>

I tried rotating the key on the old app earlier, and again just now, but no  
difference - I re-checked the scopes as well and they match exactly on the  
new (working) app and the old one.

---

<div class="post-metadata">

**Author:** ![LeeBartelme](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/leebartelme/32/95647_2.png) [@LeeBartelme](https://community.hubspot.com/u/LeeBartelme)\
**Post date:** [October 10, 2022, 3:47pm UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836/16 "2022-10-10T15:47:12Z")

</div>

Thanks, that’s good information to know.

---

<div class="post-metadata">

**Author:** ![FHaard](https://avatars.discourse-cdn.com/v4/letter/f/b487fb/32.png) [@FHaard](https://community.hubspot.com/u/FHaard)\
**Post date:** [October 8, 2022, 8:13am UTC](https://community.hubspot.com/t/custom-object-schema-creation/65836/17 "2022-10-08T08:13:38Z")

</div>

I had this issue, and it was resolved by creating a new private app and token after enterprise was activated on the account, the private app that was created before the enterprise trial was activated does not work.  
YMMV but it WorkedForMe

**TM**
