APIs & Integrations

Shivasagar
Member

Form Submission API

SOLVE

Hi Team,

 

I'm working on Hubspot form submission API. Just I want to know is there any option to filter response by a parameter ('submittedAt'). I mean to filter some time interval, for example, to get submitted data between some time interval like 1547130102576 to 1547129474539.

 

And one more thing I want know is there any option to get notified once the form is submitted using Webhook.

0 Upvotes
1 Accepted solution
jackcoldrick
Solution
HubSpot Employee
HubSpot Employee

Form Submission API

SOLVE

Hi @Shivasagar,

 

At present we have no public endpoint that would allow you to retrieve data submitted between a given date. There is an "Analytics API" that would allow you to get the number of submissions (without any data) between given dates. For example a request like this:

 

https://api.hubapi.com/analytics/v2/reports/forms/daily?hapikey={{apikey}}&start=20191101&end=20191230&f={{formID}}

Would return the following response show total submissions for a specific form between November 1st 2019 and December 30th 2020.

 

 
{
    "2019-12-27": [
        {
            "breakdown": "c1e01dbb-effe-46a3-8bb2-e89cc0c9ed51",
            "submissions": 1
        }
    ],
    "2019-12-28": [],
    "2019-12-29": [],
    "2019-12-30": []
}

In terms of using a webhook to be notified anytime a form is submitted this is possible. If you are using any of Marketing, Sales or Service Hub Enterprise you have the option of using a webhook action in your workflow. When this action is executed HubSpot will POST a payload to the webhook url you've specified that contains all of the data related to the currently enrolled contact. You could setup a workflow that enrolls contacts based on submitting "Any form" or a "Specific form" and POST the data as you like. See a screenshot of this type of setup below:

 

webhook-workflow.png

If you are not using an enterprise edition of HubSpot you could consider creating your own workflow action using our "Workflows extenion API". This works in a somewhat similar way - POSTing data to a webhook URL however you need to specify the payload.

 

I hope this information helps in some way.

 

Jack

 

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn

View solution in original post

3 Replies 3
jackcoldrick
Solution
HubSpot Employee
HubSpot Employee

Form Submission API

SOLVE

Hi @Shivasagar,

 

At present we have no public endpoint that would allow you to retrieve data submitted between a given date. There is an "Analytics API" that would allow you to get the number of submissions (without any data) between given dates. For example a request like this:

 

https://api.hubapi.com/analytics/v2/reports/forms/daily?hapikey={{apikey}}&start=20191101&end=20191230&f={{formID}}

Would return the following response show total submissions for a specific form between November 1st 2019 and December 30th 2020.

 

 
{
    "2019-12-27": [
        {
            "breakdown": "c1e01dbb-effe-46a3-8bb2-e89cc0c9ed51",
            "submissions": 1
        }
    ],
    "2019-12-28": [],
    "2019-12-29": [],
    "2019-12-30": []
}

In terms of using a webhook to be notified anytime a form is submitted this is possible. If you are using any of Marketing, Sales or Service Hub Enterprise you have the option of using a webhook action in your workflow. When this action is executed HubSpot will POST a payload to the webhook url you've specified that contains all of the data related to the currently enrolled contact. You could setup a workflow that enrolls contacts based on submitting "Any form" or a "Specific form" and POST the data as you like. See a screenshot of this type of setup below:

 

webhook-workflow.png

If you are not using an enterprise edition of HubSpot you could consider creating your own workflow action using our "Workflows extenion API". This works in a somewhat similar way - POSTing data to a webhook URL however you need to specify the payload.

 

I hope this information helps in some way.

 

Jack

 

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn
Shivasagar
Member

Form Submission API

SOLVE
Hi Jack,
 
Thank for the great inputs, Analytics API getting below error, coming to webhook don't we have an option to get notified using the developer app webhook other than creating a workflow.
{
    "status": "error",
    "message": "Unsupported Media Type",
    "correlationId": "c9ae9cc1-d18e-43b1-89fb-54b4d71dc2b4",
    "requestId": "91428890-5f5a-4251-8970-edfb134c1115"
}
0 Upvotes
jackcoldrick
HubSpot Employee
HubSpot Employee

Form Submission API

SOLVE

hi @Shivasagar,

 

The reason you are seeing that error is because you should be using HTTP GET. If you use another method it will throw an error. With regards the webhook API - we have no way of subscribing to form submissions via this API at present. What might be possible is to:

 

1) Create a workflow that increments a contact property any time a form is submitted.

2) Use the webhooks API to listen for changes to that contact property being updated

 

Screen Shot 2020-01-07 at 11.57.53 AM.png

 

Whilst this wouldn't supply you with the specific data submitted on the form. It would give you a payload like this and at least tell you when a form was submitted: 

 

"objectId": 281751 //ID OF CONTACT SUBMITTED FORM
"propertyName": "form_submission_counter" //NAME PROPERTY UPDATED
"propertyValue": "1" //VALUE OF PROPERTY
"changeSource": "AUTOMATION_PLATFORM" //SOURCE OF CHANGE (WORKFLOW)
"eventId": 3164844479  //UNIQUE ID OF EVENT
"subscriptionId": 213994 // WEBHOOK SUBSCRIPTION ID
"portalId": 2990812 // PORTAL ID
"appId": 204883 // ID OF THE APP
"occurredAt": 1578398232718 // TIMESTAMP CHANGE OCCURRED
"subscriptionType": "contact.propertyChange" //TYPE OF SUBSCRIPTION
"attemptNumber": 0 //ATTEMPT NUMBER X

You could then use the ID of the contact to pull whatever information you'd like out of HubSpot. Arguably if you are going through all of this trouble it might just be easier to trigger a webhook directly from the workflow itself. If you don't have the option of doing that (not on enterprise) you could consider creating your own workflow extension to POST the data out on form submission. 

 

I hope this helps,

Jack

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn