Public object api merge endpoint undefined in Hubspot client

Hi,

I am trying to access the new merge endpoint found here from the Hubspot client within a custom code block of a Hubspot workflow but I get this error:

“TypeError: Cannot read property ‘merge’ of undefined”

I used the Nodejs example from the docs.

It looks like the publicObjectApi isn’t accessible in the hubspot client?

I am wondering if this is maybe because it’s a relatively new endpoint?

Any help would be great.

Hey, @JHowardAdapt. It looks like @LMeert had some insight on your original post [here](http://Using%20the api client merge endpoint in custom code). @JBeatty @Kevin-C, do you have any thoughts on using this in a workflow custom coded action?

Best,

Jaycee

I tried using the example give from the docs as suggested but it throws an undefined error at the point of publicObjectApi.merge.

The exact same code works fine outside of custom code blocks, in a standard .js file.

Whereas within the custom code block it can’t seem to find the merge endpoint from the huspotclient import

Hi @JHowardAdapt,

Inside of a custom code action the included hubspot api client is version 3.4.1. The PublicObjectApi was added in version 6.0.1.
If you want to access this endpoint I would recommend using an http client like axios or request, and just manually calling the api: “/crm/v3/objects/{objectType}/merge”. Or if you absolutely must use the HubSpot client you can set up a build system and manually build in the correct version of the client using someting like esbuild. I would not recommend doing this though as it makes your custom code unreadable and quite large to someone without access to the original code.
Best,