Back to listing

Update HubSpot property




If a record already exists in HubSpot, this function allows you to update its properties. 

It's ideal for use alongside the `Search CRM` snippet. If your search returns a single result, this function can update the properties. 



Language: JavaScript


function updateObject(propertyName, propertyValue, objectType, objectId) {

        const data = {

            properties: {

                `${propertyName}: '${propertyValue}'`



        const config = {

            headers: {

                'Content-Type': 'application/json',

                'Authorization': accessToken



        axios.patch(`${objectType}/${objectId}`, data, config)

            .then(response => {

                console.log(`Successfully updated the ${objectType} with ID of ${objectId}. ${propertyName} is now has a value of ${propertyValue}`);


            .catch(error => {

                console.log(`Error while updating the ${objectType} with ID of ${objectId}. Received this error message from HubSpot: ${error.message}`);




How can SpotDev support your business?

HubSpot Migrations

Move from Salesforce, Dynamics, Pipedrive or any CRM to HubSpot with SpotDev.

Learn more

HubSpot Integrations

Add advanced functionality to your HubSpot portal with API development services.

Learn more


Align your sales, marketing and service teams to break down silos and trigger growth.

Learn more