Crest Design
HubSpot 8 min read

HubSpot custom code actions: upgrade workflows to Node 24

HubSpot froze Node.js 20 custom code actions on November 17, 2026. How HubSpot custom code actions work on Node.js 24, a before-and-after code example, a safe upgrade path and fixes for common errors.

Crest Design
Guide to upgrading HubSpot workflow custom code actions from Node.js 20 to Node.js 24.

This post is for teams whose HubSpot workflows run code: lead scoring, data clean-up, enrichment, round-robin routing or calls to another system. If any of that lives in HubSpot custom code actions, a runtime change in November 2026 affects you. You'll learn what changed, why old code needs more than a version switch, how to upgrade each action safely, and what to check if something stops working.

What changed in November 2026, and why it matters now

HubSpot announced on its developer changelog that Node.js 16 and Node.js 20 are being retired for workflow custom code actions. From November 3, 2026, new actions can't be created on Node.js 20 and Node.js 24 is available. From November 17, 2026, changes to existing Node.js 20 actions can no longer be saved, the same way Node.js 16 actions already behaved.

Here's the part people miss: your Node.js 20 actions keep running. Nothing breaks overnight. The problem shows up later, when a sales manager asks for a new routing rule or an API you call changes, and the developer opens the action only to find it's locked. At that point a small edit turns into a rewrite under time pressure.

So the real job is to move each action to Node.js 24 on your own schedule, while it's calm, rather than in the middle of an incident.

How custom code actions work on Node.js 24

A custom code action is a small function that HubSpot runs inside a workflow. It receives the enrolled record and any properties you chose to pass in, can call APIs, and hands values back as output fields that later steps can use in branches or property updates. They're part of HubSpot's programmable automation, which sits in Data Hub Professional and Enterprise (previously Operations Hub).

The runtime change isn't just a newer Node.js. Three things change in how the code is written:

  • The handler must return its outputs. On Node.js 20 and earlier, the function received a callback and passed outputs to it. Node.js 24 doesn't support callback-style handlers: exports.main must be an async function that returns an object with outputFields.
  • The bundled libraries change. The old request library is gone, so HTTP calls move to the built-in fetch or to axios. The HubSpot Node.js client moves from version 11 to version 13, and some method signatures differ between those versions.
  • Old credentials are a good thing to retire at the same time. If an action calls the HubSpot API with a token from a legacy private app, HubSpot's guidance is to move it to a service key with the same scopes, stored as a secret on the action.
How a HubSpot custom code action changes from Node.js 20 to Node.js 24: return instead of callback, fetch instead of request, client v13, service key secrets.
What changes when a custom code action moves from Node.js 20 to Node.js 24.

Why the callback change matters so much: in callback code, it was easy to call callback() inside a .then() chain and forget to handle the error path. The action would sometimes end without outputs and nobody noticed. With a returned value, an unhandled error ends the action as failed, which is noisier but far easier to spot in the workflow history.

If you've already moved integrations off legacy private apps, our guide to HubSpot service keys for legacy private app integrations explains the scopes side in more detail.

How to upgrade HubSpot custom code actions, step by step

Six steps to upgrade a HubSpot custom code action: find actions, clone the workflow, rewrite the handler, swap libraries, test a real record, switch the live action.
The upgrade path we follow for each workflow that runs custom code.

1. Make an inventory

Go to Automation > Workflows and open each workflow that contains a custom code action. For every action, note the workflow name, the runtime shown in the action panel, the secrets it uses, the properties it reads and the output fields later steps depend on. A shared spreadsheet is enough. HubSpot also suggests asking Breeze to update actions still on Node.js 16 or 20; that can save typing, but treat its changes as a draft to review, not a finished upgrade. Custom code actions can't be updated through the HubSpot CLI.

2. Work on a copy

Clone the workflow and leave the clone turned off. You'll rewrite and test there, so the live workflow keeps running on Node.js 20 until the new version is proven.

3. Rewrite the handler

Switch the action's runtime to Node.js 24, then change the function shape. Here is a typical before and after. The old version:

// Node.js 20 (callback style, can no longer be saved)
exports.main = async (event, callback) => {
  const email = event.inputFields['email'] || '';
  const domain = email.split('@')[1] || '';
  callback({ outputFields: { email_domain: domain } });
};

The Node.js 24 version, which also reads a contact property through the CRM API using a service key stored as a secret:

// Node.js 24 custom code action
// Secret on the action: HUBSPOT_SERVICE_KEY
// Property to include in code: email
// Output fields defined in the action: email_domain, lifecycle_stage
exports.main = async (event) => {
  const email = (event.inputFields['email'] || '').toLowerCase();
  const domain = email.includes('@') ? email.split('@')[1] : '';

  const url = `https://api.hubapi.com/crm/v3/objects/contacts/${event.object.objectId}?properties=lifecyclestage`;
  const res = await fetch(url, {
    headers: { Authorization: `Bearer ${process.env.HUBSPOT_SERVICE_KEY}` }
  });
  if (!res.ok) {
    throw new Error(`Contact lookup failed with status ${res.status}`);
  }
  const contact = await res.json();

  return {
    outputFields: {
      email_domain: domain,
      lifecycle_stage: contact.properties.lifecyclestage || 'unknown'
    }
  };
};

Paste it into the action's code editor, add the secret under the action's secrets, include email as a property, and define the two output fields with matching names and types. Change the property and output names to suit your own workflow.

4. Swap libraries and credentials

Replace any request calls with fetch. If you use @hubspot/api-client, check every method you call against the client's release notes for version 13 rather than assuming the old names still work. Move legacy private app tokens to a service key secret while you're in there.

5. Test with a real record

Use the Test option in the action panel with a record that represents a normal case, then one that represents an awkward case: a contact with no email, a company with no domain, a deal with no owner. Check the logs and every output field, and make sure downstream branches still receive the values they expect.

6. Switch the live action

Once the clone behaves, update the live workflow's action with the tested code (or swap the workflows over), then watch the workflow history for the next few runs. Keep the old code in your spreadsheet or repository so you can see exactly what changed.

What we've learned from runtime upgrades

Most of the effort isn't the syntax. It's discovering what an action quietly depends on: a property someone renamed, a secret nobody remembers creating, or a downstream branch that treats an empty output as "no". We'd recommend upgrading the actions that touch revenue first (routing, deal creation, lead assignment) and leaving reporting helpers for later.

When wouldn't we rewrite? If an action has grown into a mini application with several API calls, retries and its own state, a workflow action is often the wrong home. Moving that logic into a small hosted service that HubSpot calls through a webhook can be easier to test and monitor. For a single lookup or a formatting job, though, a custom code action is still the simplest place for it.

Troubleshooting

Symptom Likely cause Fix
"Changes can't be saved" on an existing action The action is still on Node.js 20 and the November 17 freeze applies Switch the runtime to Node.js 24 and rewrite the handler before saving
Action succeeds but output fields are empty The code still calls callback() instead of returning, or output names don't match Return { outputFields: { ... } } and check names and types match the action settings exactly
Error that request can't be found The library isn't bundled with Node.js 24 Rewrite the call with fetch or axios
API calls return 401 or 403 Missing secret, old private app token or missing scopes Add the service key as a secret with the same scopes and read it from process.env
"is not a function" on a HubSpot client method Method changed between client versions 11 and 13 Check the version 13 release notes and update the call, or use fetch directly

Questions people ask

Will my Node.js 20 actions stop running?

No. According to HubSpot's changelog, existing Node.js 20 actions keep running after November 17, 2026. What you lose is the ability to save changes to them, so any future fix needs the upgrade first.

Can I just change the runtime dropdown and save?

Only if the code already returns its outputs and doesn't use removed libraries. Most actions written in the callback style need the handler rewritten, and anything using request needs its HTTP calls replaced.

Should an agency do this, or our admin?

A confident HubSpot admin can handle simple actions. If actions call external systems, write to several records or sit in revenue-critical routing, it's worth having a developer review and test them.

Why it matters for your business

Custom code actions usually sit at the points where leads get assigned, records get cleaned and data moves between systems. When one of those is frozen, changes to your sales process wait on a rewrite. Upgrading now keeps your automation editable and gives you a clear inventory of what runs where, which also helps with the other November changes covered in our post on moving HubSpot serverless functions off the design manager.

A quick checklist before you close the ticket:

  • Every custom code action is listed, with its runtime, secrets and outputs.
  • Each one runs on Node.js 24 and returns its outputs.
  • No action uses request or a legacy private app token.
  • Each was tested on a normal and an awkward record in a cloned workflow.
  • The code is saved in version control.

If you'd like a second pair of eyes on your workflows, our HubSpot CMS development and workflow automation teams can audit and upgrade them, so feel free to tell us what your workflows do.

(over to you)

Planning a build like this?

Tell us what you're building and we'll come back with ideas and next steps.