API document for Unique link generation

API document for Unique link generation


What is SurveySensum Platform:


SurveySensum is a SAAS application, using the application anyone can create multiple surveys. These surveys can be shared to the customers through multiple channels like WhatsApp, Email, SMS. Once customers receive the survey, they click on the survey link (survey link which is shared via different channels), once user fills the survey on web application the response is captured SurveySensum platform. All the responses and the reporting can be viewed in SurveySensum reporting module. Below is the flow when user is manually sharing the survey form the platform.

Feedback collection flow:

Displaying Frame 1.png


Need of API integration:


Api integration is required when there is a need of sharing the survey in real time. Common use cases of real-time integration are as following:
  1. User logged in

  2. New feature launched

In these use cases SurveySensum provides REST api to communicate with the share module in SurveySensum platform to share the survey programmatically without manual interventions.


Prerequisites for API integrations:


1.     The survey should already be there in the SurveySensum. You can build the survey using the build module of SurveySensum, the SurveyGuid is required in the API call. Survey GUID can be copied from the platform URL as following screenshot:


  1. Access token for authentication

    1. Login to your SurveySensum account and go to your Account Settings.

    2. On the settings page, go to Integration and Apps, Created Apps and then click 'Create Your App'

    3. Enter the app name and a short description of your app and click on Create New App.

    4. Once you create an app, an Access token will be visible on the screen with all permissions.

    5. You can change permissions if you want to. But make sure to re-generate your Access token to apply those new permissions.

  2. Contact properties codes: Each customer of your organization is identified in SurveSensum as a contact, in the api payload property code is required.  Your customer may have information like name, email, phone number, city info, store id, region etc. Developers can ask the business user which user info they require in the survey response for further analysis. For knowing the codes you can go to SurveySensum platform-> Contacts-> Contact Properties , in the contact properties grid there is a column named “code”, in this field you can know the code for each property

Displaying Frame 12.png


Api Specs:


You can access the request API from the created app under API URL, see the below screenshot for the reference:

Displaying Frame 13.png

Request Method: Post 

Request API URL: {{baseUrl}}/v2/


Request Headers: 

Authorization: Bearer {token}

Content-type: application/json

Note: Token can be generated by logging in to SurveySensum platform-> Setting-> Integrations & Apps-> Created Apps, here you can create a new app for getting an Auth token 


Query Parameters 

Name

Type

Optional

surveyGuid

string

No

shareId

string

Yes

Json payload:

{
  "contactInfo": [
    {
      "key": "vz_c_cusId",
      "value": "cus1"
    }
  ],
  "metadata": [
    {
      "key": "Metadata prop descriptor code",
      "value": "Metadata value"
    }
  ]
}

Here's a breakdown of all the fields in the JSON payload:

  1. contactInfo (Array of key-value pairs):

    •  Purpose: This section contains contact-related information that helps personalize the survey link.

    • Structure: Each entry consists of:

      • "key": The name of the contact property.

      • "value": The actual value assigned to that contact property.

    • Example Explanation:

"contactInfo": [{ 

"key": "vz_c_cusId",

value": "cus1"

} ]

  • "vz_c_cusId" is a custom property representing the customer ID.

  • "cus1" is the value, meaning this survey link is being generated for customer with ID "cus1".

  1. metadata (Array of key-value pairs):

    • Purpose: This section holds additional contextual data related to the survey.

    • Structure: Each entry consists of:

      • "key": A descriptor that identifies the metadata property.

      • "value": The actual metadata value.

    • Example Explanation:

"metadata": [{

    "key": "Metadata prop descriptor code",

    "value": "Metadata value"}]

  • "Metadata prop descriptor code" represents a custom metadata field (e.g., "transactionId", "productCategory").

  • "Metadata value" is the actual value assigned to this metadata field.




Api Response types:

if successful execution of api : 

_________________________________

{

  "statusCode": 200,

  "result": [

    "https://cx.surveysensum.com/5aB9BA9s"

  ],

  "etag": null,

  "errors": [],

  "message": "success",

  "corelationId": null

}

--------------------------------------------------------------------------------






if No contact properties provided:

____________________________________

{

  "statusCode": 400,

  "result": null,

  "etag": null,

  "errors": [],

  "message": "Invalid/empty contact info",

  "corelationId": null

}

--------------------------------------------------------------------------------------

if metaData key not exits :

___________________________________

{

  "statusCode": 400,

  "result": null,

  "etag": null,

  "errors": [],

  "message": "invalid metadata",

  "corelationId": null

}


--------------------------------------------------------------------------------------

if Contact is Duplicate(request for link generation for same contact within throttle days):

_________________________

{

  "statusCode": 400,

  "result": null,

  "etag": null,

  "errors": [],

  "message": "One or more errors occurred. (Contact is duplicate)",

  "corelationId": null

}

--------------------------------------------------------------------------------------------------

eration api from OPENAPI.txt

Use Case Example: 

If you're sending a survey after a customer makes a purchase or logs into your system, you might populate these fields as follows:

{"contactInfo": [

    {

      "key": "customerId",

      "value": "12345"

    },

    {

      "key": "customerEmail",

      "value": "user@example.com"

    }

  ],

  "metadata": [

    {

      "key": "transactionId",

      "value": "txn_98765"

    },

    {

      "key": "productCategory",

      "value": "Electronics"

    }

  ]

}


  • "customerId": "12345" links the survey to a specific customer.

  • "customerEmail": "user@example.com" allows personalized survey communication.  "transactionId": "txn_98765" ties the survey to a specific transaction.

  • "productCategory": "Electronics" helps analyze feedback per category.



Example Curl Request: (Specific for generating survey link in BrowerStack’s  Net Promoter Score Survey)


curl -X POST "{{baseUrl}}/v2/Share/shareSurvey/link?surveyGuid=de547eec-6b36-4ce1-90ab-8e411beaf985" -H  "accept: text/plain" -H  "Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImIzYmJiNTA3YjZhMTRmMTcwYzU5MjZhMTBmODgwNDIyIiwidHlwIjoiSldUIn0.eyJuYmYiOjE3Mzg4Mzc4MzQsImV4cCI6MTc3MDM3MzgzNCwiaXNzIjoiaHR0cHM6Ly9wcm9kLWluLW1pY3JvLnN1cnZleXNlbnN1bS5jb20vc3RzIiwiYXVkIjpbImh0dHBzOi8vcHJvZC1pbi1taWNyby5zdXJ2ZXlzZW5zdW0uY29tL3N0cy9yZXNvdXJjZXMiLCJ2el9vcGVuX2FwaSJdLCJjbGllbnRfaWQiOiJmYTE2MmI3OS1lYWE4LTQxNTUtOTE4NC1jNWMxOWUzZDU1N2EiLCJzdWIiOiI4M2JjNjA1OS1lMmU0LTExZWYtYjhhMS0wMmE0YTY0NzNkMTEiLCJhdXRoX3RpbWUiOjE3Mzg4Mzc4MzMsImlkcCI6ImxvY2FsIiwiSXNQYW5lbEFsbG93ZWQiOiJGYWxzZSIsInN1YnNjcmlwdGlvbkd1aWQiOiI4N2NjOTJmZC1lMmU0LTExZWYtYjhhMS0wMmE0YTY0NzNkMTEiLCJ1c2VyR3VpZCI6IjgzYmM2MDU5LWUyZTQtMTFlZi1iOGExLTAyYTRhNjQ3M2QxMSIsInVzZXJJZCI6InJhaHVsYzI5QGdtYWlsLmNvbSIsIkZ1bGx5TWF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qPyQY4D--M8tQZ8UF_JjwM31LLiUiBS1b0CNCDj58cSBqIkPzuD1geIwjQOxFNf6r6cjQ12gC0Of_C_sfcQqOqtj1l-4rQ6ziP4Q-uzZidpxkTKG90G3QXDPolEWYxX-fHJxucuY6C40QWF-83zmiVYigzwHGnm4kxe7ZtZ5McRYfQsoVWukRuvmx9p4rz5NfPDFz05JDfEPuEJpkAHMSgtX3cKHO8Q01xYLJcrCdTxJnBMv3Pn2ES7pIUOIDhnumT1K2yWDGLd6zTrUGJNTwOxfei4OJsImg" -H  "Content-Type: application/json-patch+json" -d "{\"contactInfo\":[{\"key\":\"vz_c_email\",\"value\":\"email1@email.com\"}],\"metadata\":[{\"key\":\"transactionId\",\"value\":\"t1\"}]}"