POST: https://{{env}}.survey2connect.com/v2/api/collectors/{{collect_id}}/campaigns/external
The value of environment {{env}} variable depends upon your datacenter. Refer to the Environment page for more details.
"Content-Type": "application/json"
type: Api Key Key: x-api-key token: value from portal
Request Parameters
{{collect_id}}: Unique Collector ID.
Request Body
{ "contacts": [{ "email": "john1@s2c.com", "city": "Delhi", "extUniqueId": "123" }, { "email": "john2@s2c.com", "city": "Mumbai", "extUniqueId": "124" }] }
Supported Filters
Field | Type | Mandatory | Description |
collectortoken | String | Yes |
It is unique for every collector. Can be captured from the platform.
|
contacts | Array | Yes |
Array for contacts for whom you want to generate survey links. Also, you can add custom information of the respondents along with it.
‘extUniqueId’ is mandatory. |
Request Sample
curl --location --request POST 'https://az1.survey2connect.com/v2/api/collectors/6375dad04b732a3b38d2f51b/campaigns/external' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJraWQiOiJzM3E1OWF2cFdIcXVKa0I0MjRpcFpqQVN0dXAzQzFkZEhVM3k2TjNZSXRjPSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI0MTIxMDc1NC01ODVkLTRjNmQtODc2NC02Mzg0NzJkYTRhODEiLCJ6b25laW5mbyI6InByb2RfYXoxIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImN1c3RvbTpwYXNzd29yZFRvQmVSZXNldCI6ImZhbHNlIiwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLmFwLXNvdXRoLTEuYW1hem9uYXdzLmNvbVwvYXAtc291dGgtMV9zalNzc2JrOXYiLCJwaG9uZV9udW1iZXJfdmVyaWZpZWQiOmZhbHNlLCJjdXN0b206dUlkIjoiNjExYmEzNTcwZjdhNDEyNDYxM2MyMzg2IiwiY29nbml0bzp1c2VybmFtZSI6IjQxMjEwNzU0LTU4NWQtNGM2ZC04NzY0LTYzODQ3MmRhNGE4MSIsImF1ZCI6Ijg1azh1b2RqODBpazUzb2F0cDRycWJsYmMiLCJldmVudF9pZCI6IjJjYzgxNzA4LTdiN2ItNDZlYi04OTM2LTBkOWMyOTU1YjgzNCIsInRva2VuX3VzZSI6ImlkIiwiYXV0aF90aW1lIjoxNjY5MTA5NTA4LCJjdXN0b206c3RhdHVzIjoiYWN0aXZlIiwibmFtZSI6IlRlc3QgRCIsInBob25lX251bWJlciI6Iis5MTc0MTc0NjExNzYiLCJleHAiOjE2NjkxOTYwMDMsImN1c3RvbTpyb2xlIjoiYnJhbmRBZG1pbiIsImlhdCI6MTY2OTEwOTYwMywiZW1haWwiOiJkYXZpbmRlci5zQHN1cnZleTJjb25uZWN0LmNvbSJ9.j0yBmCrkCtjPvgAOcFlwfpv5CQwfejHrMPUoIOAom0Z7czPeCcm09MZQdOph-IRNTkHk6_eRGUhXvXBIkIFbORDSugL95JEzZiuiDQyC2smB_ft5sy3UmlLWDy2GchvJyyvqI1UK8QEa2Qytk68vNM40Y3VZGj9J_Poq7Kq_I7K5iISE-QY51s1A37Hkgm7rqVbcfUbtE6yM5vJP2JuybiGPRs_WBtQFIwURI7lVCkOEIcZJCLF7mA3lTC7GzXTODTeF3zKteUGFch9IWXU0oCDY9PwFRp2H2BSyAu74iRBcrkWBt4XMgDnT3ePlIfu0Y-vK-XrEiUo-ZiLyo0pEyg' \
--data-raw '{
"collectortoken": "T/ae67354b",
"contacts": [{
"email": "john1@s2c.com",
"city": "Delhi",
"extUniqueId": "123"
}, {
"email": "john2@s2c.com",
"city": "Mumbai",
"extUniqueId": "124"
}]
}'
var myHeaders = new Headers(); myHeaders.append("Authorization", "Bearer eyJraWQiOiJzM3E1OWF2cFdIcXVKa0I0MjRpcFpqQVN0dXAzQzFkZEhVM3k2TjNZSXRjPSIsImFs "); myHeaders.append("Content-Type", "application/json"); var raw = JSON.stringify({ "collectortoken": "E/f1a0f500", "medium": 2, "contacts": [ { "email": "john1@s2c.com", "city": "Delhi", "extUniqueId": "123" }, { "email": "john2@s2c.com", "city": "Mumbai", "extUniqueId": "124" } ] }); var requestOptions = { method: 'POST', headers: myHeaders, body: raw, redirect: 'follow' }; fetch("https://survey2connect.com/v2/api/collectors/62e20646bfbefb48636eaf50/campaigns/external", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));
Responses
{ "msg": "Request data is correct", "data": [ { "extUniqueId": "123", "message": "We are conducting a survey and your input would be appreciated. Open the link below to start the survey. Thank you for your participation! https://s2ccx.com/7gtdu4U" }, { "extUniqueId": "124", "message": "We are conducting a survey and your input would be appreciated. Open the link below to start the survey. Thank you for your participation! https://s2ccx.com/txsXRkF" } ], "rejected_list": [], "accepted": 2, "rejected": 0 }
{ "error": { "name": "Bad Request", "message": "Collector not found" } }
{ "error": { "name": "Unauthorized", "message": "The authorization token was not provided." } }
{ "error": { "name": "Internal Server Error", "message": "We were not able to process your request" } }
Note: Please do not share your tokens in publicly accessible areas or to anyone. Also, this token generated is valid for 24 hours only. After its expiry, you can regenerate the access token from the same API endpoint by passing the username and password or from the refresh token API with the help of refresh token.