Quick tipDeveloperMarketing Hub

Submit a custom form to HubSpot through the forms API, and keep tracking

Posting to the forms API instead of creating contacts directly keeps form submission history, consent and analytics.

Subscription
All tiers
Permissions
Form ID and, for the secure endpoint, an access token
Time
5 min · Advanced
Last verified

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.

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