Nudge API Documentation
About the Nudge API
The Nudge API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs. This document is intended to describe the Nudge APIs through which users can access data and perform operations in the “Nudge" Platform. Click here to explore the swagger tool for testing the Nudge APIs.
Base URL: All the endpoints are accessible through the app.nudge.net host."""""
How to get access to the Nudge API
To understand the API document, you just need to review the application's main objects involved in the API calls.
1. Sign Up
Signing up for an account is quick and easy! Just click on the Register and answer a few questions, and you can start exploring the Nudge.
If you're facing any issues. You can follow the below link to register the account successfully.
https://help.nudge.net/article/162-introduction-to-nudge
2. Save your App's key and keep them secure
The registered user will get authenticated through the API key, which is unique for registered users. It is system-generated, which will be created by the user in the “Nudge" Platform and will be used later in the API requests, such as importing contact data, scheduling nudges, sending real-time nudges, etc. The registered user can generate more than one API key in his nudge account.
Since these keys do not expire unless deleted, we suggest that you save them in a secure location.
Steps for Generating API Key
- Click on “Name” from the top right side.
- Click on “Configuration” from the popup menu
- Click on the “API Management” tab
- Click on “Create new API Key”
- Enter the name of your API key & click on the “Generate” button
- Copy the Key & click on the “Done” button.
Example of API Key: L1B/PUgtBPVu9wEbhTx7LnuiGuqplbEA+D7Wj28uAiOyaqqZBimqGFucQkzAYROrKdfbiz/tx5Xqsy4YVdDW2w==
To create an API key, the user must have to be registered in the “Nudge" Platform.
3. API Gateway URL
The Nudge API Gateway URL is https://app.nudge.net. You need to include this before each API endpoint to make API calls.
4. Public APIs
4.1 Send Real-Time Nudge
Prerequisites
Create a template first. Create Email Template - Nudge
Create a Real-Time Nudge following the last section of the document - Create Email Nudge - Nudge
Resource Description
The real-time nudge will be scheduled using this API call which can be an email, SMS, or WhatsApp or Push notification nudge.
POST /v1/Nudge/Send
Headers
Authorization | <API_KEY> |
Content-Type | application/json |
Payload
The nudgeId and channel both are required parameters for this API request.
The channel can be between 0 to 4.
Email (0) - The toEmailAddress is required parameter for this API request.
SMS (1)/WhatsApp (2)/IVR (4) - The toPhoneNumber is required parameter for this API request.
Push Notification (3) - The recipeintId is required parameter for this API request.
JSON body
{
"nudgeId": 0,
"recipientId": "string",
"toEmailAddress": "string",
"emailCc": "string",
"emailBcc": "string",
"emailAttachments": [
{
"content": "string",
"mimeType": "string",
"fileName": "string"
}
],
"toPhoneNumber": "string",
"toName": "string",
"mergeTags": [
{
"tagName": "string",
"tagValue": "string"
}
],
"channel": 0
}
Request body
The API call will be authorized through the user’s API key. The Curl for the scheduling real-time nudge will be:
curl -X 'POST' \
'https://app.nudge.net/api/v1/Nudge/Send' \
-H 'accept: application/json' \
-H 'Authorization: <API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"nudgeId": 1387,
"toPhoneNumber": "91XXXXXXXXXXX"
"mergeTags": [
{
"tagName": "Email_Address",
"tagValue": "example@example.com"
}
],
"channel": 1
}'
Response
The response to scheduling a real-time nudge will be:
{
"data": {
"notificationLogId": "string"
},
"code": 200,
"errors": [],
"hasErrors": false,
"errorGuid": null
}
After getting the response, you can check the record in the Notification log in the Nudge application.
4.2 Import Contact data for recurring Nudge - /v1/ContactData/Import
Prerequisites
Create a template first. Create Email Template - Nudge
Create a Recurring Time Nudge following this document - Create Email Nudge - Nudge
Resource description
The user will upload contact data in a CSV file for existing recurring nudges.
POST /v1/ContactData/Import
Headers
Authorization | <API_KEY> |
Content-Type | application/json |
Payload
The nudgeId, channel, and file are required parameters for this API request.
Form-data parameters
NudgeId | 0 (Integer Value) |
Channel | 0/1/2/3/4 (Email=0, SMS=1, WhatsApp=2, Push Notifications=3, IVR=4) |
File | contact.csv (CSV file) |
Request body
The API call will be authorized through the user’s API key. The Curl for the import contact data (csv) file for recurring nudge will be:
curl -X 'POST' \
'https://app.nudge.net/api/v1/ContactData/Import' \
-H 'accept: application/json' \
-H 'Authorization: <API_KEY>' \
-H 'Content-Type: multipart/form-data' \
-F 'NudgeId=0' \
-F 'Channel=0' \
-F 'File=<FILE>;type=text/csv'
Response
The response to import contact data (CSV) file for recurring nudge will be:
{
"data": {
"recipientIdWarning": null
},
"code": 200,
"errors": [],
"hasErrors": false,
"errorGuid": null
}
After getting the response, you can verify the CSV file by Edit the nudge in the Nudge application
4.3 Launch Nudge
Resource Description
The One-time nudge will be scheduled using this API call. It can be any type of nudge such as email, SMS, WhatsApp, Push notification, or IVR. It can be scheduled for future dates too.
Prerequisites
Create a template first. Create Email Template - Nudge
Create a One Time Nudge following this document - Create Email Nudge - Nudge
POST /v1/Nudge/Launch
Resource URL
To send the scheduled nudge now, the following URL will be used: https://app.nudge.net/api/v1/Nudge/Launch
Headers
'Authorization | <API_KEY> |
'Content-Type | application/json |
Payload
The nudgeId and channel both are required parameters for this API request.
The channel can be between 0 to 4.
Email=0, SMS=1, WhatsApp=2, Push Notification=3, IVR=4
The format for scheduledAt parameter is “YYYY-MM-DD HH:mm:ss”
JSON body
{
"nudgeId": 0,
"channel": 0,
"scheduledAt": "string", "ianaTimeZoneId": "string"
}
Request body
The API call will be authorized through the user’s API key. The Curl for the scheduling nudge will be:
curl -X 'POST' \
'https://app.nudge.net/api/v1/Nudge/Launch' \
-H 'accept: application/json' \
-H 'Authorization: <API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"nudgeId": 0,
"channel": 0,
"scheduledAt": "YYYY-MM-DD HH:mm:ss",
"ianaTimeZoneId": "Asia/Kolkata"
}'
Response
The response to sending a scheduled nudge will be:
{
"code": 200,
"errors": [],
"hasErrors": false,
"errorGuid": null
}
After getting the response, you can check the record in the Notification Log in the Nudge application.
4.4 Get Notification statistics
Resource Description
The user can see the Notification Logs using this API call. It can be any type of nudge, such as email, SMS, WhatsApp, or Push.
POST /v1/NotificationStats
Headers
'Authorization | <API_KEY> |
'Content-Type | application/json |
Payload
The channel is required parameters for this API request.
Form-data parameters
NudgeId | 0 (Integer Value) |
Channel | 0/1/2/3/4 (Email=0, SMS=1, WhatsApp=2, Push Notifications=3, IVR=4) |
RecipientId | String |
FromTime | yyyy-MM-dd or yyyy-MM-dd HH:mm:ss |
ToTime | yyyy-MM-dd or yyyy-MM-dd HH:mm:ss |
Status | 0 to 14 (Created=0, Processing=1, Sent=2, Failed=3, Delivered=4, Undelivered=5, Read=6, Processed=7, Dropped=8, Deferred=9, Bounce=10, Open=11, SpamReport=12, Click=13, Received=14) |
String | |
MobileNumber | String |
Skip | Default value 0 |
Top | Default value 0 |
Request body
The API call will be authorized through the user’s API key. The Curl for the get nudge notification logs will be:
curl -X 'POST' \
'https://app.nudge.net/api/v1/NotificationStats' \
-H 'accept: application/json' \
-H 'Authorization: <API_KEY>' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'Channel=0&Email=hassanm%40utilli.com&Skip=0&Top=10'
Response
The response to get nudge notification logs will be:
{
"data": {
"pageData": [
{
"guid": "00000000-0000-0000-0000-000000000000",
"recipientId": null,
"toEmail": "example@example.com",
"mobileNumber": null,
"scheduledOn": "",
"status": 4,
"nudgeName": "",
"nudgeRunId": 0,
"clicksCount": 0
},
{
"guid": "00000000-0000-0000-0000-000000000000",
"recipientId": "XXXX",
"toEmail": "example@example.com",
"mobileNumber": null,
"scheduledOn": "",
"status": 4,
"nudgeName": "",
"nudgeRunId": 0,
"clicksCount": 1
}
],
"totalCount": 2
},
"code": 200,
"errors": [],
"hasErrors": false,
"errorGuid": null
}
4.4 Get Enrollment/Survey Responses
Resource Description
The user can see the stats for Enrolment/Survey using this API call.
POST /v1/EnrollmentStats
Headers
'Authorization | <API_KEY> |
'Content-Type | application/json |
Payload
The EnrollmentName is required parameters for this API request.
Form-data parameters
EnrollmentName | String |
RecipientId | String |
FromTime | yyyy-MM-dd or yyyy-MM-dd HH:mm:ss |
ToTime | yyyy-MM-dd or yyyy-MM-dd HH:mm:ss |
Skip | Default value 0 |
Top | Default value 0 |
Request body
The API call will be authorized through the user’s API key. The Curl for the get enrolment stats will be:
curl -X 'POST'
'https://app.nudge.net/api/v1/EnrollmentStats'
-H 'accept: application/json'
-H 'Authorization: <API_KEY>'
-H 'Content-Type: application/x-www-form-urlencoded'
-d 'EnrollmentName=<ENROLLMENT_NAME>&Skip=0&Top=10'
Response
The response to get enrolment stats will be:
{ "data": { "pageData": [ {
"recipientId": "", "submitTime": "", "reportForms": [ {
"id": "", "name": "<ENROLLMENT_NAME>", "value": "" },
{
"id": "", "name": "<ENROLLMENT_NAME>", "value": "" },
{
"id": "", "name": "<ENROLLMENT_NAME>", "value": "" },
{
"id": "", "name": "<ENROLLMENT_NAME>", "value": null },
{
"id": "", "name": "<ENROLLMENT_NAME>", "value": "" }
]
},
{
"recipientId": "3214", "submitTime": "2023-06-21T08:09:12.858043Z", "reportForms": [ {
"id": "", "name": "<ENROLLMENT_NAME>", "value": "" },
{
"id": "", "name": "<ENROLLMENT_NAME>", "value": "" },
{
"id": "", "name": "<ENROLLMENT_NAME>", "value": "" },
{
"id": "", "name": "<ENROLLMENT_NAME>", "value": null },
{
"id": "", "name": "<ENROLLMENT_NAME>", "value": "" }
]
}
],
"totalCount": 2 },
"code": 200, "errors": [], "hasErrors": false, "errorGuid": null }