- Quick Start
- Send Survey
- Get Contact
- Remove Contact
- Delete Contact (GDPR)
- Get Unsubscribed
- Get Responses
- Get NPS
- Sent Statistics
- Historical Stats
- Deactivate All
- Bulk Add with CSV
- Inapp Surveys
- Bulk Add/Send
Change Log
Trigger Survey
These methods will trigger a survey to a contact.
The API will only obey the *first contact* rule found on the Send page of AskNicely.
The API will not import any contact with an email address blocked by the Blocklist.
This API does not work with multivalue, please reference our Bulk Add/Send API.
Arguments
Using the base url https://DEMO.asknice.ly/api/v1/contact/trigger
, the following arguments can be sent via a HTTP POST request:
Argument | Example | Required | Description |
---|---|---|---|
email |
schrodinger@example.com |
Required | Contact email |
name |
Erwin Schrodinger |
Optional | Full name, optionally you can send the argument firstname and lastname |
addcontact |
true |
Optional | Set this to addcontact = false to add the contact and send a survey for the contact if global contact rules allow. If addcontact is set to true, the contact will only be added/updated within AskNicely, no survey email will be sent. This is the best option if you want to use the daily scheduler to manage the email sending. |
triggeremail |
true |
Optional | If set to true, the API will always send a survey, we recommend to only use this
parameter for testing the API to see the survey emails being sent. Remove this entirely when in production,
as including this parameter will override all contact rules and send a survey for each API call.
Setting triggeremail=false won't stop it from sending surveys.
|
delayminutes |
10 |
Optional | If you want to trigger a survey to have a delay, use delayminutes. 10 = 10 minute delay. 7 day delay would be 60*24*7 = 10800, there is no limit to how minutes or days you can delay. This value ignored for sms, surveys are always sent immediately. |
segment |
VIP Customer |
Optional | Set a customers segment |
customproperty |
California |
Optional | Add extra argments to send through extra custom data to help identify/filter/leaderboard customers. Multiple arguments can be sent with each request. |
thendeactivate |
true |
Optional | After a survey has been sent, de-activate this customer so they are not eligible for NPS surveys sent via
the Daily Scheduler on the Send page. This function only works in conjunction with the triggeremail=true function.
If you wish to de-activate a customer regardless of if a survey is sent or not,
please use the remove contact API.
Very handy if you are using both the Daily Scheduler and API calls. |
Example CURL request
curl --data "email=schrodinger@example.com&name=Erwin Schrodinger&triggeremail=true" --header "X-apikey: " \Remove triggeremail=true in production, this setting is used to always force a survey to be sent when testing.
https://DEMO.asknice.ly/api/v1/contact/trigger
Example of CURL request containing segment and custom data (city)
curl --data "email=schrodinger@example.com&name=Erwin Schrodinger&triggeremail=true" --header "X-apikey: " \
https://DEMO.asknice.ly/api/v1/contact/trigger?segment=green&city=portland
Responses
Successfully sent
{ "result":[ { "survey_sent":true, "id":"15968", "email":"john@asknice.ly", "msg":"Message Sent" } ], "success":true, "surveys_sent":1 }
Includes id
of the customer updated or created and their email address
Customer has been contacted within your contact rules
{ "result":[ { "survey_sent":false, "id":"15968", "email":"john@asknice.ly", "msg":"You have already contacted this contact within the period of your contact rules, this request will be ignored. Add parameter '&triggeremail=true' to override contract rules and trigger this survey. " } ], "success":true, "surveys_sent":0 }
Customer is not active or has un-subscribed
{ "result":[ { "survey_sent":false, "id":"15968", "email":"john@asknice.ly", "msg":"This contact has been de-activated or has un-subscribed, your survey will not be sent" } ], "success":true, "surveys_sent":0 }
Includes id
of the customer updated or created and their email address