CMS Hub Enterprise ships with serverless functions. Most teams use them for one form handler and forget. They’re more capable than that. Four patterns that replace AWS Lambda, Vercel functions, or whatever else you’re paying for.
1. Custom form endpoint with enrichment
The native HubSpot form posts directly to the CRM. That’s fine until you want to enrich the submission with a third-party API call (Clearbit, ZoomInfo, your own data) before writing to the contact.
serverless/enrich-form.functions.json -> POST /enrich
serverless/enrich-form.js -> calls enrichment API, then HubSpot API
exports.main = async (context) => {
const { email } = context.params;
const company = await fetch(`https://api.enrich.com/?email=${email}`).then(r => r.json());
await context.hs.crm.contacts.basicApi.update(email, {
properties: { company_size: company.size, industry: company.industry }
});
return { statusCode: 200, body: { ok: true } };
};
2. Custom thank-you redirect logic
After form submission, redirect by lifecycle stage, geo, or campaign. The form’s static thank-you URL doesn’t cut it. A serverless function reads the contact, decides, redirects.
3. Tokenized download links
Generate signed URLs for gated content downloads. The download URL expires in 24 hours and is bound to the contact ID, preventing the “send the URL to a friend who never converted” problem.
4. Webhook receiver with logic
Other systems push events to HubSpot. A serverless function is a cleaner receiver than a workflow webhook because you get full request/response control, validation, and error handling.
exports.main = async (context) => {
if (context.headers["x-signature"] !== expectedSig(context.body)) {
return { statusCode: 401 };
}
// process event, write to CRM
return { statusCode: 200 };
};
What serverless functions can’t do
Long-running jobs (over 10 seconds). Heavy compute (no GPU, limited memory). Anything requiring persistent connections (no WebSockets). For those, use a real backend.
Cost ceiling
Serverless functions are bundled with CMS Enterprise but have execution limits per portal. Past those, you’re back to paying. Architect with that ceiling in mind; offload heavy traffic to your own infra.
Local dev workflow
hs functions deploy --src=./serverless --dest=/myfunctions
hs logs --function=enrich-form --tail
Local emulation is rough. Most teams test in a dev portal. Build a CI step that deploys to dev on every PR and runs smoke tests.
What to do this week
Pick one form on your site that needs enrichment or custom routing. Build the serverless function. Stop paying for the AWS Lambda doing the same job.