Webhooks

Customer Data Platform

What is a Webhook?

A webhook is an HTTP request triggered by an event in a source system (in this case, Sprig) and sent to a destination system with a payload of data. Webhook requests are automatically sent out when their event is triggered in Sprig.

What Webhook Events Does Sprig Support?

Sprig supports webhooks triggered by the following events:

  • Answer submitted - a user submits an answer to a specific question in a study.
  • Study submitted - a user completes and submits a study.
  • Study sent - Sprig has triggered and delivered a study.
  • Study seen - a user has viewed a study.
  • Theme identified - Sprig identifies a new theme associated with a study.
  • Study status changed - a study becomes paused, completed, etc.

Currently, Sprig supports Bearer Tokens for webhook authentication. The webhook is sent as an HTTP POST request to the specified endpoint, in JSON format.

You can have different Webhook configurations for each Product and Environment.

Configuring Webhooks in Sprig

To receive webhooks from Sprig to a destination system:

  1. Navigate to Integrations > Destinations > Webhook and click Configure.
  2. Select the Production or Development environment.
  3. Enter the destination system's Payload URL.
  4. Enter the Bearer Token API Secret (Bearer_is automatically prepended to the _authorization: header field).
  5. Check which events in Sprig you want to trigger a Webhook request.
  6. Click Test Webhook to see if the request posts to the destination system.
  7. Click Save to save the configuration.

Example cURL equivalent of the Test Webhook request

curl -X 'POST' 'https://webhook.site/96255364-4d38-4be5-a6e4-795881dc5b6b?' -H 'connection: close' -H 'host: webhook.site' -H 'content-length: 92' -H 'user-agent: axios/0.21.2' -H 'authorization: Bearer APIsecret' -H 'content-type: application/json' -H 'accept: application/json, text/plain, */*' -d $'{"id":1,"environmentId":"abc123","surveyId":1,"surveyName":"TEST_SURVEY","eventType":"TEST"}'

Example Payloads for Each Event

Answer Submitted

PropertyTypeDescription
idIntegerWebhook ID
environmentIdStringInternal Environment ID
createdAtDatetimeCreation date and time
responseGroupUidStringUUID for the Group of Responses sent by a User
responseString | Integer | List | ObjectResponse Text or Option to the Question. This can be an Integer, String, or List, or Object.
surveyIdIntegerUnique Survey ID
surveyNameStringSurvey name/title
questionStringQuestion wording
questionTypeStringQuestion type (open, nps, multipleselect, matrix, etc.)
visitorIdStringVisitor ID
oldVisitorIdintegerLegacy Vistor ID
userIdStringUser ID
anonymousIdStringSegment data not used by Sprig
triggeringEventStringEvent name of event that initiated study for visitor
timestampTimestampTime of response in UTC unix milliseconds epoch
emailStringEmail address of the user
attributesmapA key-value map of custom attributes you can set on the user
hrefStringURL where study was activated if web study
osStringOperating system of device if collected from SDK
browserStringBrowser that study was activated if web study
userAgentStringInformation about platform visitor used if collected from SDK
customMetadataObjectA key-value map of custom metadata you can set on the url of link studies, empty map otherwise
selectedIndexesInteger | ListThis field can either be an Integer of a List of Integers, depending on the question type. If the question type is "multiplechoice", this field will be an Integer. If the question type is "multipleselect", this field will be a List of Integers.
eventTypeStringThe type of event that triggers the webhook
eventNameStringName of Event under the Event Type
eventPropertiesObjectA key-value map of event properties that were set to target this visitor, empty map otherwise.
JSON example
{
  "id": 234211,
  "environmentId": "ENVIRONMENT_ID",
  "createdAt": "2022-08-16T17:57:33.603Z",
  "responseGroupUid": "3305ee6c-15f4-4a55-a478-2c5f4adb9798",
  "response": "[\"SUV\"]",
  "surveyId": 11220,
  "surveyName": "What Is Your Preferred Transportation Method?",
  "question": "What models of car do you prefer?",
  "questionType": "multipleselect",
  "visitorId": "ba050493-0292-4099-9262-8e18c7406e81",
  "oldVisitorId": 0,
  "userId": "2603",
  "anonymousId": null,
  "triggeringEvent": exit_rental_booking,
  "timestamp": 1660672653789,
  "email": "[email protected]",
  "attributes": {
    "plan": "Enterprise",
    "role": "admin"
  },
  "href": "https://retails.cars.com/surveys/11220",
  "os": "Mac OS X",
  "browser": "Chrome",
  "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36",
  "customMetadata": "{}",
  "selectedIndexes": "[2]",
  "eventType": "survey_response",
  "eventName": "surveyResponse",
  "eventProperties": {
    "string-event-property": "string"
  }
}

Theme Identified

PropertyTypeDescription
themenamestringTheme Name
updatedAtdate/timedate and time
productIdstringID of the product
environmentIdstringEnvironment ID
questionTextstringQuestion body text
questionTypestringType of Question
JSON example
{
  "themename": "testthemeNew8",
  "updatedAt": "2022-02-22T19:31:05.089Z",
  "productName": "iOS Test Account",
  "productId": 20110,
  "environmentId": "RpOLQFy3T",
  "questionText": "The iOS Test Account team has a video question for you",
  "questionType": "videovoice"
}

Study Submitted

PropertyTypeDescription
visitorIdstringunique ID of the survey respondent
platformstringStudy delivery method
surveyIdstringID of the survey
timestampTimeUTC timestamp of when survey was completed
environmentIdstringEnironment ID
eventDatedate / timeDatestamp of when survey was completed in UTC
recordTypestringWill always be Survey
actionstringwill always be completed
responseGroupUidintegerUUID of Response Group (used for debugging purposes)
productNamestringName of Sprig Product configured by the Customer
productIdintegerInternal Numeric Id of Product (used for debugging)
questionsstringAll the questions in the survey with responses if available
questionstringQuestion instance
responsestringResponse to the question
orderstringorder of question in the survey
eventTypestringEvent type
JSON example
{
  "visitorId": "2341e79f-9b73-49d0-884d-d1f168aa9511",
  "platform": "link",
  "surveyId": 8529,
  "timestamp": 1645562173173,
  "environmentId": "RpOLQFy3T",
  "eventDate": "2022-02-22T20:36:13.011Z",
  "recordType": "survey",
  "action": "completed",
  "responseGroupUid": "91355295-f316-40f3-85e5-dec3e7b2ec72",
  "productName": "iOS Test Account",
  "productId": 20110,
  "eventName": "surveySubmitted",
  "questions": [
    {
      "question": "I am testing something",
      "response": 3,
      "order": 1
    }
  ],
  "eventType": "product_message"
}

Study Status Changed

PropertyTypeDescription
surveyIdstringunique ID of the survey (used for debugging)
surveyNamestringName of the Survey
oldStatusstringOld status of the survey
statusstringUpdated status of the survey (possible values are "NEW", "IN_PROGRESS", "PAUSED", "COMPLETED")
environmentIdstringEnvironment ID
productNamestringName of Sprig Product configured by the Customer
productIdintegerInternal Numeric Id of Product (used for debugging)
eventNamestringName of Event under the Event Type
questionsstringAll the questions in the survey
questionstringQuestion text
questionTypeIdintegerType of question
eventTypestringEvent type (will always be product message in this json object)
JSON example
{
  "surveyId": 77694,
  "surveyName": "Test Survey for Webhooks",
  "oldStatus": "NEW",
  "status": "IN_PROGRESS",
  "environmentId": "RpOLQFy3T",
  "productName": "iOS Test Account",
  "productId": 20110,
  "eventName": "surveyStatusChange",
  "questions": [
    {
      "question": "What is one plus one?",
      "questionTypeId": "open"
    },
    {
      "question": "How likely are you to recommend iOS Test Account to a friend or colleague?",
      "questionTypeId": "nps"
    }
  ],
  "eventType": "product_message"
}

Study Sent

PropertyTypeDescription
isUserInterviewsbooleanTrue if Link Study with User Interviews integration enabled
platformstringStudy delivery method
timestamptimeUTC timestamp of when survey was completed
recordTypestringrecord type will always be "survey"
eventDatedate/timeDatestamp of when survey was completed in UTC
visitorIdstringunique ID of the survey respondent
environmentIdstringEnvironment ID
surveyIdintegersurvey ID
actionstringwill always be completed
responseGroupUidintegerUUID of Response Group (used for debugging purposes)
productNamestringName of Sprig Product configured by the Customer
productIdintegerInternal Numeric Id of Product (used for debugging)
eventNamestringName of Event under the Event Type
triggeringEventstringEvent name of event that initiated study for visitor
surveyNamestringName of the Sprig Study
attributesobjectObject of attributes set on the visitor if available
emailstringEmail address if set
oldVisitorIdnullDeprecated
userIdstringUser ID if set
anonymousIdstringSegment Anonymous ID if set
customMetadataobjectCustom metadata if set for Link Study response
eventTypestringEvent type
JSON example
{
  "isUserInterviews": false,
  "platform": "web",
  "timestamp": 1711987848970,
  "recordType": "survey",
  "eventDate": "2024-04-01T16:10:48.970Z",
  "visitorId": "0209f2ad-27db-4080-bf8b-2fdae11a2649",
  "environmentId": "",
  "surveyId": 0,
  "action": "seen",
  "responseGroupUid": "38b1a6fe-13ed-477f-ab04-af53f9ecd499",
  "productName": "Earl Test",
  "productId": 0,
  "teamId": 0,
  "eventName": "studySeen",
  "triggeringEvent": "sprig",
  "surveyName": "Survey Test",
  "attributes": {},
  "email": "",
  "oldVisitorId": null,
  "userId": null,
  "anonymousId": null,
  "customMetadata": "{}",
  "eventType": "product_message"
}

Study Seen

PropertyTypeDescription
visitorIdstringunique ID of the survey respondent
timestampTimeUTC timestamp of when survey was completed
environmentIdstringEnvironment ID
platformstringStudy delivery method
recordTypestringrecord type will always be "survey"
eventDatedate/timeDatestamp of when survey was completed in UTC
surveyIdintegerWill always be Survey
actionstringbe completed ID
responseGroupUidintegerUUID of Response Group (used for debugging purposes)
productNamestringName of Sprig Product configured by the Customer
productIdintegerInternal Numeric Id of Product (used for debugging)
eventNamestringName of Event under the Event Type
triggeringEventstringEvent name of event that initiated study for visitor
surveyNamestringName of the Sprig Study
attributesobjectObject of attributes set on the visitor if available
emailstringEmail address if set
oldVisitorIdnullDeprecated
userIdstringUser ID if set
anonymousIdstringSegment Anonymous ID if set
customMetadataobjectCustom metadata if set for Link Study response
eventTypestringEvent type
JSON example
{
  "visitorId": "0209f2ad-27db-4080-bf8b-2fdae11a2649",
  "timestamp": 1711987848665,
  "environmentId": "",
  "platform": "web",
  "recordType": "survey",
  "eventDate": "2024-04-01T16:10:48.665Z",
  "surveyId": 0,
  "action": "sent",
  "responseGroupUid": "38b1a6fe-13ed-477f-ab04-af53f9ecd499",
  "productName": "Demo Product",
  "productId": 0,
  "teamId": 0,
  "eventName": "studySent",
  "triggeringEvent": "studyEventTrigger",
  "surveyName": "Survey Test",
  "attributes": {},
  "email": "",
  "oldVisitorId": null,
  "userId": null,
  "anonymousId": null,
  "customMetadata": "{}",
  "eventType": "product_message"
}