I referred link Get started with serverless functions - HubSpot docs to create serverless function.
This is my hubspot.config.yml:
defaultPortal: HubSpot_Assignment
portals:
- name: HubSpot_Assignment
portalId: 8943172
authType: personalaccesskey
auth:
tokenInfo:
accessToken: >-
XXX
expiresAt: '2021-06-07T10:19:46.023Z'
personalAccessKey: >-
XXX
My congratulation.js file is as follows:
exports.main = (context, sendResponse) => {
// your code called when the function is executed
const functionResponse = "Congrats! You've just deployed a Serverless Function."
// sendResponse is a callback function you call to send your response.
sendResponse({body: functionResponse, statusCode: 200});
};
I tried to access this url https://api.hubapi.com/_hcms/api/congratulation
But I am getting
Page Not Found Error
on Browser
Hi everyone! 
Just adding a quick update for anyone coming across this thread.
The original solution still applies: CMS serverless functions should be accessed through a domain connected to your HubSpot account, rather than api.hubapi.com.
For example, a CMS serverless endpoint would use a URL like:
https://yourdomain.com/_hcms/api/your-endpoint
Keep in mind that HubSpot’s serverless functionality has evolved since this discussion in 2021. Project-based serverless functions are also available in Developer Platform 2026.03, with a different endpoint structure and configuration.
For current setup instructions, I’d recommend checking HubSpot’s serverless functions documentation.
Hope this helps anyone running into a similar issue! 
@DKachhawaha ,
You are loading the wrong address. It will be available under whatever domain your portal is using.
If your portal domain was example.com, it would be https://www.example.com>/_hcms/api/congratulation
Moderator Note: this post was reviewed for relevancy and optimized for clarity on October 23, 2026. Thank you for your contributions to the HubSpot Community!
Thanks for the solution.I am new to this platform.
Could you please tell me where can I find my domain name for my account.
And also the files which i created like javascript files or yml files are they to be created in IDE like VScode or in Design Manager of HubSpot Account
@DKachhawaha ,
This kb " Understand and manage system domains " should get you to where your domain is located. If you haven’t set a domain up yet, when you get to the domains settings, it will be empty. Click on language settings and you will see it there.
As for the second question, I recommend using a local web development workflow when possible which I believe was advised in that doc that you referenced above. Here is another doc " HubSpot CLI commands overview - HubSpot docs " that explores it in more detail.
Good luck!