Quick tipDeveloperContent Hub

HubSpot CMS serverless functions: what they are for, and the 10-second limit

Serverless functions let a HubSpot page call your code without a separate server. They are built for quick calls.

Subscription
Check serverless availability for your Content Hub subscription
Permissions
Developer access to the CMS
Time
4 min · Advanced
Last verified

Short answer

Serverless functions run server-side JavaScript for HubSpot CMS pages, such as form handling or calling another API with a secret. HubSpot's docs say each function can run for at most 10 seconds, and hitting execution count or time limits returns 429. Execution time is recorded in the function logs.

1. A minimal function

// functions/hello.js
exports.main = async (context) => {
  return { statusCode: 200, body: { ok: true, q: context.params } };
};

2. Limits to plan for

  • 10 seconds per execution. Long jobs belong elsewhere.
  • Execution count limits per minute, also returning 429.
  • Keep secrets in HubSpot secrets, not in page code.

3. Related

Deploying with the CLI: hs project upload. For workflow-side code: custom code actions.

Sources

New field notes by email

One email when a new article publishes.

Still stuck?

If this did not fix it, the problem is probably specific to your setup. Book a call and we will look at it together.

Book a call with Sam