- 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.
API Endpoint
Make a HTTPS POST request to
Arguments
The following parameters 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 arguments firstname and lastname
|
addcontact |
true |
Optional | 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. Set this to addcontact=false to also send a survey for the contact if global contact
rules allow.
|
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. |
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.
|
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. |
segment |
VIP Customer |
Optional | Set a customers segment |
customproperty_c |
California |
Optional | Add any number of extra arguments to send through additional custom data fields to help identify/filter/leaderboard customers. Multiple arguments can be sent with each request. While it's not strictly required, we recommend to suffix your keywords with `_c` to avoid conflicts with reserved custom data names. |
Example CURL requests
Force a survey (during development)
curl -X POST \ --data-urlencode "email=schrodinger@example.com" \ --data-urlencode "name=Erwin Schrodinger" \ --data-urlencode "triggeremail=true" \ --header "X-apikey: " \ https://DEMO.asknice.ly/api/v1/contact/triggerRemove triggeremail=true in production, this setting is used to always force a survey to be sent when testing.
Example of CURL request containing segment and custom data ("city")
curl -X POST \ --data-urlencode "email=schrodinger@example.com" \ --data-urlencode "name=Erwin Schrodinger" \ --data-urlencode "triggeremail=true" \ --data-urlencode "segment=green" \ --data-urlencode "city_c=portland" \ --header "X-apikey: " \ https://DEMO.asknice.ly/api/v1/contact/trigger
Responses
Successfully sent
{ "result":[ { "survey_sent":true, "id":"15968", "email":"schrodinger@example.com", "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":"schrodinger@example.com", "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":"schrodinger@example.com", "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 and their email address