CreateCustomObject
Creates a custom object in HubSpot. Requires private-app token authentication if OAuth scopes are insufficient.
Execute
When you need to create a custom object you also need to define its schema (properties).
There are two ways to do that. The first way is to feed the whole json aggregate (for the properties) to the Properties input, as shown below:
EXECUTE CreateCustomObject
ObjectName = 'DevObject',
ObjectLabelSingular = 'Dev',
ObjectLabelPlural = 'Devs',
RequiredProperties = 'TestDev',
SearchableProperties = 'TestDev,TestNumber',
PrimaryDisplayProperty = 'TestDev',
SecondaryDisplayProperties = 'TestNumber',
AssociatedObjects = 'Contacts',
Properties = '[
{
\"name\": \"nameinternal\",
\"label\": \"Name\",
\"groupName\": \"group1\",
\"description\": \"The Name of the Machine.\",
\"displayOrder\": \"1\",
\"hidden\": \"false\",
\"type\": \"string\",
\"fieldType\": \"textarea\"
},
{
\"name\": \"modelinternal\",
\"label\": \"Model\",
\"groupName\": \"group1\",
\"description\": \"The model of the Machine.\",
\"displayOrder\": \"2\",
\"hasUniqueValue\": \"true\",
\"type\": \"enumeration\",
\"fieldType\": \"radio\",
\"options\": [
{
\"label\": \"Model-GT\",
\"value\": \"GT\",
\"description\": \"GT Model\",
\"displayOrder\": \"1\",
\"hidden\": \"true\"
},
{
\"label\": \"Model-AF\",
\"value\": \"AF\",
\"description\": \"AF Model\",
\"displayOrder\": \"2\",
\"hidden\": \"true\"
},
{
\"label\": \"Model-Z\",
\"value\": \"Z\",
\"description\": \"Z Model\",
\"displayOrder\": \"3\",
\"hidden\": \"true\"
},
{
\"label\": \"Model-0\",
\"value\": \"0\",
\"description\": \"0 Model\",
\"displayOrder\": \"4\",
\"hidden\": \"false\"
}
]
},
{
\"name\": \"orderdateinternal\",
\"label\": \"OrderDate\",
\"groupName\": \"group1\",
\"description\": \"The order date of the Machine.\",
\"displayOrder\": \"3\",
\"hasUniqueValue\": \"false\",
\"type\": \"date\",
\"fieldType\": \"date\"
},
{
\"name\": \"stockinternal\",
\"label\": \"Stock\",
\"groupName\": \"group1\",
\"description\": \"The number of machines in stock.\",
\"displayOrder\": \"-1\",
\"hasUniqueValue\": \"false\",
\"type\": \"number\",
\"fieldType\": \"number\"
}
]'
The second way is to make use of the Driver #TEMP tables for the aggregate value.
To do that, you need to execute the following:
INSERT INTO Properties#Temp (PropertyName, PropertyLabel, PropertyGroupName, PropertyType, PropertyFieldType) VALUES ('TestNumber', 'Dev Number', 'group1', 'number', 'number')
INSERT INTO Properties#Temp (PropertyName, PropertyLabel, PropertyGroupName, PropertyType, PropertyFieldType) VALUES ('TestDev', 'Test Dev', 'group1', 'string', 'text')
After creating the temporary table with the properties, we can execute the stored procedure as shown below:
EXECUTE CreateCustomObject
ObjectName = 'DevObject',
ObjectLabelSingular = 'Dev',
ObjectLabelPlural = 'Devs',
RequiredProperties = 'TestDev',
SearchableProperties = 'TestDev,TestNumber',
PrimaryDisplayProperty = 'TestDev',
SecondaryDisplayProperties = 'TestNumber',
AssociatedObjects = 'Contacts',
Properties = 'Properties#Temp'
If one of the initial properties is of the type enumeration, you first need to create a temporary table with property options, as shown below:
INSERT INTO PropertyOptions#Temp (OptionLabel, OptionValue, OptionDescription, OptionDisplayOrder, OptionHidden) VALUES ('TRUE', 'true', 'Yes', 1, false)
INSERT INTO PropertyOptions#Temp (OptionLabel, OptionValue, OptionDescription, OptionDisplayOrder, OptionHidden) VALUES ('False', 'false', 'No', 2, false)
After creating the temporary table with the property options, you need to create the temporary table with the properties. First, set the property options temporary table name (created above) as the value of the Options column. Then, create a record, which is the type enumeration. This temporary table is shown below:
INSERT INTO Properties#Temp (PropertyName, PropertyLabel, PropertyGroupName, PropertyType, PropertyFieldType, Options) VALUES ('TestEnumeration', 'Dev Enumeration', 'group1', 'enumeration', 'radio', 'PropertyOptions#Temp')
INSERT INTO Properties#Temp (PropertyName, PropertyLabel, PropertyGroupName, PropertyType, PropertyFieldType) VALUES ('TestDev', 'Test Dev', 'group1', 'string', 'text')
After creating the temporary table with the properties, we can execute the stored procedure as shown below:
EXECUTE CreateCustomObject
ObjectName = 'DevObject',
ObjectLabelSingular = 'Dev',
ObjectLabelPlural = 'Devs',
RequiredProperties = 'TestDev',
SearchableProperties = 'TestDev',
PrimaryDisplayProperty = 'TestDev',
SecondaryDisplayProperties = 'TestEnumeration',
AssociatedObjects = 'Contacts',
Properties = 'Properties#Temp'
PropertyOptions temporary table schema info:
| Column Name | Type | Required | Description |
| OptionLabel | string | true | Human-readable label for an enumerated option. Required if PropertyFieldType is set to an option-based input like select or radio. |
| OptionValue | string | true | Internal value corresponding to the enumerated label. This value is used when setting the property through the API. |
| OptionDescription | string | false | Optional description for the enumerated option. Appears as help text to clarify the option's meaning or use. |
| OptionDisplayOrder | integer | false | Order in which this option appears in the UI. Lower positive integers appear first; -1 causes the option to appear last. |
| OptionHidden | boolean | false | Specifies whether the option should be hidden from the HubSpot interface. Hidden options can still be used via API. |
Properties temporary table schema info:
| Column Name | Type | Required | Description |
| PropertyName | string | true | The internal name of the property. This is used in API requests and must remain consistent for integrations and automation. |
| PropertyLabel | string | true | The display label for the property as shown in HubSpot's UI. It should be easily understandable to end users. |
| PropertyGroupName | string | false | Optional grouping label for organizing related properties in the HubSpot UI under a shared section. |
| PropertyDescription | string | false | Optional help text that appears in the HubSpot UI to guide users on how to fill out the property. |
| PropertyDisplayOrder | integer | false | Defines the order in which this property appears in the UI relative to others. Lower numbers appear first; -1 positions the property after all others. |
| PropertyHasUniqueValue | boolean | false | Specifies whether the property value must be unique across all object records. Once enabled, this setting cannot be changed. |
| PropertyHidden | boolean | false | Specifies whether the property is hidden from the HubSpot user interface, preventing users from seeing or editing it directly. |
| PropertyType | string | true | Defines the data type of the property. Accepted types include string, number, date, enumeration, and datetime. |
| PropertyFieldType | string | true | Determines how the property is rendered in the HubSpot interface, such as text input, date picker, dropdown, or checkbox. Must be compatible with the specified PropertyType. |
| Options | string | false | Required only if PropertyType is set to enumeration. The input values should be a temporary table (#TEMP). |
Input
| Name | Type | Description |
| ObjectName | String | Unique identifier for the custom object type within the schema. This name must be unique and is used when referencing the object in the API. |
| ObjectLabelSingular | String | The singular form of the custom object's label, shown in the CRM interface to represent a single instance of the object. |
| ObjectLabelPlural | String | The plural form of the custom object's label, shown in the CRM interface to represent multiple instances of the object. |
| RequiredProperties | String | A comma-separated list of properties that must be populated when creating an instance of this custom object. |
| SearchableProperties | String | A comma-separated list of properties that is indexed by HubSpot and included in CRM-wide search functionality. |
| PrimaryDisplayProperty | String | Name of the main property shown as the object's primary identifier in HubSpot records. |
| SecondaryDisplayProperties | String | A comma-separated list of names of additional properties displayed as secondary information under the primary property on the object record page. |
| AssociatedObjects | String | A comma-separated list of Hubspot object names. Defines which other standard or custom objects can be associated with this custom object type. |
| Properties | String | The Properties for the object to be created. The input value must be a temporary table (#TEMP). |
Result Set Columns
| Name | Type | Description |
| Success | Boolean | Specifies whether the custom object was successfully created through the procedure. |
| ObjectName | String | Name of the custom object that was created, used for API and internal reference. |
| ObjectLabel | String | Plural label of the created custom object, used for display in the HubSpot interface. |
| ErrorCode | String | Numeric or symbolic code indicating the reason the procedure failed, if applicable. |
| ErrorMessage | String | Detailed message describing the error that occurred during the creation of the custom object. |