Adding properties to an existing custom object via the API

Hey there,

We’ve successfully created a custom object via the API. No problems there.

At some point, we decided we wanted to add one or more properties to this custom object and figured we’d use the PATCH endpoint to make this happen. Something along these lines:

curl --location --request PATCH 'https://api.hubapi.com/crm/v3/schemas/<custom object name>?hapikey=<API KEY>' \
--data-raw '{
 "name": "<custom object name>",
 "properties": [
 {
 "groupName": "",
 "displayOrder": "-1",
 "hasUniqueValue": "false",
 "hidden": "false",
 "name": "newly_created_property_via_patch",
 "type": "string",
 "fieldType": "text",
 "label": "Property Created Via Patched",
 "description": "Testing custom objects with patching",
 "options": []
 }
 ]
}'

When we execute the above, we get a 200 but the new property that we’ve included in the “properties” array isn’t actually added to the custom object.

So, what’s the correct way to do this via the API (without deleting the custom object and recreating with all of the properties)? We know we can add these properties through the HubSpot UI but that’s not really an option for what we’re trying to do.

Thanks.

- Terence

Hi @tarh33l

Check out the properties api which you would use for all objects

Well, that was pretty bone-headed on my part :(. Thanks for pointing me in the right direction.

On a related note - it appears that we can only refer to the custom object in API calls (like the properties endpoints) using the “fullyQualifiedName” on the custom object, as opposed to the name we originally used when we defined the object.

So, for example, if the name we pass in the POST for “/crm/v3/schemas” is “my_custom_object”, the resulting fullyQualifiedName will be something like “p12345_my_custom_object”. This really isn’t ideal since the calls we’re making to create the properties on said custom object don’t know the fully qualified name.

Is there a way to add properties to the object using the original name of the custom object instead of the fully qualified name?

Thanks.

Hey @tarh33l

You are going to have to stick with FQN or you can also use the objectTypeId. I prefer the object type as it is visible in the url when in the HubSpot app UI.

eg: https://app.hubspot.com/contacts/:portalid/objects/**:objectTypeId**/views/all/list.

PS, I don’t think it was a bone headed move. :upside_down_face: