When a HubSpot workflow needs real code, and when it does not

Most automation problems are configuration problems. A few genuinely need logic. Knowing which is which saves a lot of unnecessary JavaScript.

28 October 2026 · 6 min read

Custom code is the most powerful tool available in a workflow and the one most often reached for too early. A rule expressible with dropdowns should stay in dropdowns, because the next person to maintain it will thank you.

There are, though, problems that configuration genuinely cannot express, and working around them tends to produce worse systems than simply writing the ten lines.

Signs you do not need code

If the task is reformatting a value, mapping one list onto another, extracting a substring, doing date arithmetic or associating records by a shared value, there is a configured action for it. Those run faster, fail more clearly and need no maintenance.

Reaching for code here usually means writing something that a dropdown already does, and owning it forever.

Signs you do

Logic that depends on several inputs at once, like a scoring model, collapses into branch sprawl when expressed as conditions. In code it is a dozen readable lines in one place.

Calls that require a signed token, a multi-step exchange, or a response that must be interpreted before use are the same story: possible to fake with a chain of steps, far clearer as code.

Keep secrets out of the workflow

Credentials pasted into a workflow field end up in screenshots, exports and audit findings. Storing them encrypted and referencing them by name in code keeps them out of the places people look.

The same applies to data you must share but should not expose: hashing identifiers inside the workflow means the raw values never leave the CRM.

Build it

Each of these is a working pattern with the exact steps, using the actions this article describes.

Run Custom Code
Convert a private PDF link into a public URL
Files uploaded to HubSpot are private by default. When a workflow needs to email a quote or push a document to another system, the stored link fails for anyone outside the portal, so teams fall back to downloading the file and re-uploading it somewhere public.
Read the walkthrough
Run Custom Code
Score leads with your own model
Scoring that depends on several signals at once turns into a sprawl of branches in HubSpot, and nobody remembers why a lead scored what it did. Changing one weight means editing the whole tree.
Read the walkthrough
Run Custom Code
Call an internal API with a signed JWT
Internal services usually expect a signed token rather than a static key, which HubSpot's native actions cannot produce. The usual workaround is a middleware service that exists only to sign requests.
Read the walkthrough
Hash and Encrypt
Build audience match keys
Ad platforms require hashed identifiers. Hashing them outside HubSpot means exporting raw email addresses, which is precisely the data you should not be moving around.
Read the walkthrough

A good rule: if you can describe the logic as a sentence with no conjunctions, configure it. If the sentence needs three clauses and a caveat, write the code.

Put this to work in your workflows

Install AuPerate once and every action appears in your HubSpot workflow editor.

Get Started