Please note: this API is currently in beta and is subject to change based on testing and feedback. By using these endpoints you agree to adhere to HubSpot’s Developer Terms & Developer Beta Terms. You also acknowledge and understand the risk associated with testing an unstable API.
Scope requirements
The following scopes are required for the survey API endpoints, based on the endpoint you plan on using:surveys.read: provides access to retrieve survey overview data.surveys.write: provides access to create, edit, and delete surveys, as well as create and delete survey submission data.
Create a survey
To create a survey, make aPOST request to /surveys/v3/surveys, and include the name, language, and fields parameters for the survey in the body of your request, which are documented in the table below. At this time, you can only create a custom survey with a single CSAT or NPS question via this endpoint. You can create up to 100 total custom surveys in a HubSpot account.
| Parameter | Type | Description |
|---|---|---|
| name | String | An internal name for the survey that will appear in your HubSpot account. This name is not visible to respondents. |
| language | String | The language of the survey that will be used to translate default survey content (e.g., NPS label, default survey title, and introduction). |
| fields | Array | An array of JSON objects that specifies each field in the survey. Each object should include the following properties:
|
id of the newly created survey, along with a shareableLink you can use to send to a customer.
For example, if you made a POST request to https://api.hubapi.com/surveys/v3/surveys with the following request body:
Retrieve a survey
To retrieve a specific survey, make aGET request to /surveys/v3/surveys/{surveyId}, providing the ID of the survey as the surveyId.
The response will include key information about the survey, such as the name, fields, shareableLink, createdAt, and lastUpdatedAt properties, along with the sourceType property that will specify whether the survey was created via the API (api) or via the feedback tool in HubSpot (ui).
For example, if you made a request to retrieve a survey with an ID of 10, you’d make a GET request to https://api.hubapi.com/surveys/v3/surveys/10, and the response would resemble the following:
Search for survey overview data
To get a list of existing surveys, you can make aPOST request to /surveys/v3/surveys/search, and provide the limit or after query parameters to paginate the results. You can also provide an array of filterGroups and sorts in the request body to filter the results further. Learn more about how to use the search API.
The response will include the following fields:
| Field | Type | Description |
|---|---|---|
results | Array | An array of results, each of which will include the following survey properties:
|
total | Number | The total number of results. |
paging | Object | An object that provides pagination information. This will not be included if no further results remain. If present, this field will contain a next field, which itself contains an after field you can use to request the next page of results. Learn more about paginating results. |
POST request to https://api.hubapi.com/surveys/v3/surveys/search?limit=2, and your request body would resemble the following:
Delete a survey
To delete a survey, make aDELETE request to /surveys/v3/surveys/{surveyId}, providing the ID of the survey you want to delete as the surveyId.
If successfully deleted, the response will include a status code of 204 No content.
Create a feedback submission associated with a survey
To create a feedback submission to a custom survey you’ve created via the API, make aPOST request to /surveys/v3/surveys/{surveyId}/submissions, providing the ID of the survey as the surveyId, and providing details for the submission in the body of your request. The following fields are supported in the request body:
| Field | Type | Description |
|---|---|---|
email | String | A required field indicating the email address associated with the submission. |
submissionFields | Array | A list of populated fields associated with the submission. For a valid submission, the order and type of these fields must match those on the submitted survey. Each object in the array must include the following properties:
|
10, you’d make a POST request to https://api.hubapi.com/surveys/v3/surveys/10/submissions and the request body would resemble the following:
Delete a feedback submission associated with a survey
To delete an existing feedback submission, you can make aDELETE request to /surveys/v3/surveys/{surveyId}/submissions/{feedbackSubmissionId}, providing the ID of the survey as the surveyId and the ID of the feedback submission you want to delete as the feedbackSubmissionId.
If successfully deleted, the response will include a status code of 204 No content.