AskNicely's API is one of the most powerful solutions for adding contacts and data and triggering surveys.
To access the API documentation on your account, simply navigate from the dashboard to Settings->API. You can also access it directly any time by navigating to yourdomain.asknice.ly/help
Our generic API endpoint document can be found here: https://demo.asknice.ly/help/apidocs/responses
In this article, we're going to focus on Asknicely's two API endpoints that you can use to add contacts and data, and also trigger surveys:
- Send Survey
- Bulk Add/Send
"Send Survey" API endpoint
The "send survey" endpoint is used import and survey a single contact. It is a HTTP POST request that will import an email address and name along with any custom data fields you wish to provide.
In this example, I'm going to use the "Send Survey" API call to add the contact Jason AskNicely along with some custom data fields and trigger a survey
Since the Account's domain is "hinzeomatic," the API endpoint i will use is https://hinzeomatic.asknice.ly/api/v1/contact/trigger
In my API call, I will need to include a contact name, email address, and also some custom data indicating the city this contact lives in and which company they belong to. That would API call would look like the following:
And this would be what the contact record looks like in AskNicely after that API call:
Bulk Add/Send Endpoint
The 2nd of AskNicely two API endpoints for adding contacts and sending surveys is the "Bulk Add/Send" endpoint. Unlike the "send survey" endpoint, this is designed to import and survey a group of contacts instead of an individual.
This endpoint requires that contacts and data be put in a JSON object to be sent.
You can access your account's documentation on this endpoint by visiting yourdomain.asknice.ly/help/bulkasync
In this example, I'll be using the Bulk Add/Send API endpoint to import and survey a group of contacts. In order to do this, I'll need a JSON object containing all of the contacts I want to import along with any custom data I want to include. I'll be using the JSON in photo below
Notice that the JSON has a top-level property called "contacts" You will need to include that property in your JSON as well. If wish to survey the contacts when submitting this call, be sure to include the argument "obeyrules:true" in your JSON, otherwise the contacts will just be added, and not surveyed.
The endpoint URL for this is yourdomain.asknice.ly/api/v1/contacts/add