How to update properties for custom object via API

Hi Team,

We have created a custom object which is required for our business purpose and am trying to patch a property in this custom object . Can some one help me on this ? I did patch on contacts based on email address it was successful but not this one.

crm/v3/objects/contacts/p.ielat@xxx.com?idProperty=email

am trying to do same with my custom object

Hello @PAlapati
For a custom object in HubSpot via API, you can use the Patch Object Properties endpoint. Here’s an example code snippet that demonstrates how to update the properties for a custom object.

var client = new RestClient("https://api.hubapi.com/crm/v3/objects/custom_object_type/{object_id}");
var request = new RestRequest(Method.PATCH);
request.AddHeader("accept", "application/json");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer YOUR_ACCESS_TOKEN");

// Replace {object_id} with the ID of the custom object that you want to update
request.AddParameter("object_id", "{object_id}", ParameterType.UrlSegment);

// Specify the properties that you want to update
var properties = new JObject();
properties.Add("property_name_1", "new_value_1");
properties.Add("property_name_2", "new_value_2");
// Add more properties as needed

var requestBody = new JObject();
requestBody.Add("properties", properties);

request.AddParameter("application/json", requestBody.ToString(), ParameterType.RequestBody);

IRestResponse response = client.Execute(request);

you need to replace {object_id} with the ID of the custom object that you want to update. You also need to specify the properties that you want to update in the properties object. Each property should be represented as a key-value pair in the properties object, where the key is the name of the property and the value is the new value that you want to set for the property.

Note that the property names in the properties object should be in the format property_name, where property_name is the name of the custom property in HubSpot. Also, the value of each property should be of the same data type as the property in HubSpot.

Finally, you can execute the PATCH request using the Execute method of the RestClient class, as shown in the code snippet.

Thanks Himanshu for responding back !!! Just wondering if there is a way to patch based on property like email address . Patch to contact does allow idProperty to be set. But i dont see the same for custom objects. Is there a way to do the same ?