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.