Short answer
Send submissions to api.hsforms.com/submissions/v3/integration/secure/submit/{portalId}/{formGuid} with a fields array and a context object. Include hutk (the hubspotutk cookie) and the page URI so the submission joins the visitor's page views and source. Errors come back with types such as BLOCKED_EMAIL. Creating contacts with the CRM API skips all of that.
1. The request
POST https://api.hsforms.com/submissions/v3/integration/secure/submit/{portalId}/{formGuid}
{
"fields": [
{ "objectTypeId": "0-1", "name": "email", "value": "visitor@example.com" },
{ "objectTypeId": "0-1", "name": "firstname", "value": "Pat" }
],
"context": {
"hutk": "VALUE_OF_HUBSPOTUTK_COOKIE",
"pageUri": "https://www.example.com/contact",
"pageName": "Contact us"
}
}
2. Why not just create a contact
- Form submissions trigger form-based workflows and lists.
- The hutk links earlier anonymous page views to the new contact.
- Blocked domains and consent settings on the form still apply. See form spam settings.
3. Alternatives
If you only need HubSpot to capture an existing HTML form, the non-HubSpot forms setting may do it without code. See non-HubSpot forms. For embedding HubSpot's own form, see embedding forms.