- 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
Bulk Addition of Contacts with optional Survey Send
This API endpoint is asynchronous.
Use this Bulk Add API call if you want to add more than one contact and trigger surveys for those added where required.
When the API is used to also send a survey to the contacts, it will apply the Global Contact rules generally, but does not apply the exception for newly added contacts.
If a contact has un-subscribed from AskNicely emails, adding them again will not re-subscribe a customer.
API Endpoint
Make a HTTPS POST to
JSON Structure
The JSON structure must have one property called "contacts"
which contains a list (array) of your contacts as objects.
The contact objects require an email as a mandatory field. In addition you can add additional data points
for your contacts such as name, segment and contact specific data for each of your custom data fields e.g.
"custom_field_c": "Custom Value"
.
You can add multiple values to your custom data fields too e.g.
"custom_field_c": ["Custom Value","Another Custom Value"]
.
Setting "obeyrules": true
will trigger a survey to contacts that are eligible based on the value
provided for your trigger field segment
and Contact Rules on
the Send page.
Limits
The API has a payload limit of 6MB.
Example Requests
Example CURL to bulk add contacts only
curl -X \ POST https://DEMO.asknice.ly/api/v1/contacts/add \ --header "X-apikey: " \ --data-binary @- << JSON { "contacts": [ { "name": "Erwin Schrodinger", "email": "schrodinger@example.com" }, { "name": "John Smith", "email": "john@example.com" } ] } JSON
Example CURL to Bulk Add contact with custom values
curl -X POST \ https://DEMO.asknice.ly/api/v1/contacts/add \ --header "X-apikey: " \ --data-binary @- << JSON { "contacts": [ { "name": "Erwin Schrodinger", "email": "schrodinger@example.com", "custom_field_c": "Custom Value" }, { "name": "John Smith", "email": "john@example.com", "another_custom_field_c": "Another Custom Value" } ] } JSON
Example CURL to Bulk Add a contact with custom fields having values
curl -X POST \ https://DEMO.asknice.ly/api/v1/contacts/add \ --header "X-apikey: " \ --data-binary @- << JSON { "contacts": [ { "name": "Erwin Schrodinger", "email": "schrodinger@example.com", "custom_field_c": [ "Custom Value", "Another Custom Value" ] } ] } JSON
Example CURL to bulk add/update contacts & trigger a survey
curl -X POST \ https://DEMO.asknice.ly/api/v1/contacts/add \ --header "X-apikey: " \ --data-binary @- << JSON { "contacts": [ { "name": "Erwin Schrodinger", "email": "schrodinger@example.com", "obeyrules": true }, { "name": "John Smith", "email": "john@example.com", "obeyrules": true } ] } JSON
Responses
Successful |
||
---|---|---|
HTTP Status | Description | Response |
201 | Successfully added/updated |
{ "success": true } |
Unsuccessful / Errors |
||
HTTP Status | Description | Response |
400 | Contacts data is missing |
{ "success": false, "msg": "no data found", } |
400 | Contacts JSON data is malformed |
{ "success": false, "msg": "Errors found in json - {error}", }Where {error} is one of:
|
400 | Contacts JSON data is OK but format is incorrect |
{ "success": false, "msg": "if set, contacts must be an array", } |
500 | There was a server error |
{ "success": false, "msg": "Internal Server Error", } |
500 | Request is larger than 6MB |