NPS® Surveys
Note: This API endpoint is deprecated. Zendesk is removing Net Promoter Score℠ (NPS®) survey functionality on April 30, 2023. For more information, see Announcing the removal of Net Promoter Score (NPS).
The Surveys API can be used to list all surveys or retrieve and update an existing survey. You can customize the content and settings of the survey before using the Invitations API to automate the delivery of your survey to recipients.
JSON format
Surveys are represented as JSON objects with the following properties:
Name | Type | Read-only | Mandatory | Description |
---|---|---|---|---|
comments_question | string | false | false | The question to request feedback. Supports dynamic content. |
created_at | string | true | false | When the survey was created. |
delivery_method | string | false | false | The delivery method of the survey. Default: "email". Allowed values are "email", or "web_widget". |
email_subject | string | false | false | The subject text of the email. Default: "How likely are you to recommend [Company]?" |
from_email_id | integer | false | false | The chosen sender email ID. Default: ID of the default support address of the account. |
highlight_color | string | false | false | The color used to highlight certain elements in the survey email and the survey page. |
id | integer | true | false | Automatically assigned when survey created. |
intro_text | string | false | false | The introductory text of the email. Default: (Empty String). |
name | string | false | false | The name of the survey for your internal use. |
relationship_id | integer | false | false | The ID of relationship value used for the survey question. |
status | string | true | false | Status of the survey. Allowed values are "closed", "draft", or "open". |
subject | string | false | false | The subject of the survey. For example, your company name. |
updated_at | string | true | false | When the survey was last updated. |
Valid relationship_id
values are:
- 0: a friend or colleague
- 1: a friend
- 2: a friend or family member
- 3: a colleague
- 4: someone you know
Example
{
"comments_question": "Will you share why?",
"created_at": "2013-08-29T00:00:00-07:00",
"delivery_method": "email",
"email_subject": "How likely are you to recommend [Company]?",
"from_email_id": 10001,
"highlight_color": "#77a500",
"id": 1,
"intro_text": "Hi Richard, how are you today?",
"name": "After Purchase Survey",
"relationship_id": 4,
"status": "open",
"subject": "Zendesk Support",
"updated_at": "2013-08-29T00:00:00-07:00"
}
List Surveys
GET /api/v2/nps/surveys
List existing surveys.
Allowed for
- Admins
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/nps/surveys.json \
-v -u {email_address}:{password}
Go
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://support.zendesk.com/api/v2/nps/surveys"
method := "GET"
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "username:password"
client := &http.Client {}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
import com.squareup.okhttp.*;
OkHttpClient client = new OkHttpClient();
HttpUrl.Builder urlBuilder = HttpUrl.parse("https://support.zendesk.com/api/v2/nps/surveys")
.newBuilder();
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", Credentials.basic("your-email", "your-password"))
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {
method: 'GET',
url: 'https://support.zendesk.com/api/v2/nps/surveys',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic <auth-value>', // Base64 encoded "username:password"
},
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python
import requests
url = "https://support.zendesk.com/api/v2/nps/surveys"
headers = {
"Content-Type": "application/json",
}
response = requests.request(
"GET",
url,
auth=('<username>', '<password>'),
headers=headers
)
print(response.text)
Ruby
require "net/http"
uri = URI("https://support.zendesk.com/api/v2/nps/surveys")
request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")
request.basic_auth "username", "password"
response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|
http.request(request)
end
Example response(s)
200 OK
// Status 200 OK
{
"surveys": [
{
"comments_question": "Will you let us know why?",
"created_at": "2020-06-01T00:00:00-07:00",
"delivery_method": "email",
"email_subject": "How likely are you to recommend us?",
"from_email_id": 10001,
"highlight_color": "#77a500",
"id": 1,
"intro_text": "Hi, this is a follow-up to your recent purchase.",
"name": "After Purchase Survey",
"relationship_id": 4,
"status": "open",
"subject": "Zendesk Support",
"updated_at": "2020-06-01T00:00:00-07:00"
}
]
}
Show Survey
GET /api/v2/nps/surveys/{survey_id}
Shows an existing survey.
Allowed for
- Admins
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
survey_id | integer | Path | true | ID of survey. |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/nps/surveys/{survey_id}.json \
-v -u {email_address}:{password}
Go
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://support.zendesk.com/api/v2/nps/surveys/1234"
method := "GET"
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "username:password"
client := &http.Client {}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
import com.squareup.okhttp.*;
OkHttpClient client = new OkHttpClient();
HttpUrl.Builder urlBuilder = HttpUrl.parse("https://support.zendesk.com/api/v2/nps/surveys/1234")
.newBuilder();
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", Credentials.basic("your-email", "your-password"))
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {
method: 'GET',
url: 'https://support.zendesk.com/api/v2/nps/surveys/1234',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic <auth-value>', // Base64 encoded "username:password"
},
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python
import requests
url = "https://support.zendesk.com/api/v2/nps/surveys/1234"
headers = {
"Content-Type": "application/json",
}
response = requests.request(
"GET",
url,
auth=('<username>', '<password>'),
headers=headers
)
print(response.text)
Ruby
require "net/http"
uri = URI("https://support.zendesk.com/api/v2/nps/surveys/1234")
request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")
request.basic_auth "username", "password"
response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|
http.request(request)
end
Example response(s)
200 OK
// Status 200 OK
{
"survey": {
"comments_question": "Will you let us know why?",
"created_at": "2020-06-01T00:00:00-07:00",
"delivery_method": "email",
"email_subject": "How likely are you to recommend us?",
"from_email_id": 10001,
"highlight_color": "#77a500",
"id": 1,
"intro_text": "Hi, this is a follow-up to your recent purchase.",
"name": "After Purchase Survey",
"relationship_id": 4,
"status": "open",
"subject": "Zendesk Support",
"updated_at": "2020-06-01T00:00:00-07:00"
}
}
Update Survey
PUT /api/v2/nps/surveys/{survey_id}
Updates an existing survey.
Allowed for
- Admins
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
survey_id | integer | Path | true | ID of survey. |
Example body
{
"survey": {
"comments_question": "Will you let us know why?",
"email_subject": "How likely are you to recommend [Company]?",
"from_email_id": 10001,
"highlight_color": "#77a500",
"intro_text": "Hi Richard, how are you today?",
"name": "After Purchase Survey",
"relationship_id": 4,
"subject": "Zendesk Support"
}
}
Code Samples
curl
curl \
--data \
'{"survey": { \
"comments_question": "Will you let us know why?", \
"created_at": "2020-06-01T00:00:00-07:00", \
"delivery_method": "email", \
"email_subject": "How likely are you to recommend us?", \
"from_email_id": 10001, \
"highlight_color": "#77a500", \
"id": 1, \
"intro_text": "Hi, this is a follow-up to your recent purchase.", \
"name": "After Purchase Survey", \
"relationship_id": 4, \
"status": "open", \
"subject": "Zendesk Support", \
"updated_at": "2020-06-01T00:00:00-07:00" \
}}' \
--header "Content-Type: application/json" \
--request PUT \
-v -u {email_address}:{password} \
https://{subdomain}.zendesk.com/api/v2/nps/surveys/{survey_id}.json
Go
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
url := "https://support.zendesk.com/api/v2/nps/surveys/1234"
method := "PUT"
payload := strings.NewReader(`{
"survey": {
"comments_question": "Will you let us know why?",
"email_subject": "How likely are you to recommend [Company]?",
"from_email_id": 10001,
"highlight_color": "#77a500",
"intro_text": "Hi Richard, how are you today?",
"name": "After Purchase Survey",
"relationship_id": 4,
"subject": "Zendesk Support"
}
}`)
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "username:password"
client := &http.Client {}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
import com.squareup.okhttp.*;
OkHttpClient client = new OkHttpClient();
HttpUrl.Builder urlBuilder = HttpUrl.parse("https://support.zendesk.com/api/v2/nps/surveys/1234")
.newBuilder();
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
"""
{
\"survey\": {
\"comments_question\": \"Will you let us know why?\",
\"email_subject\": \"How likely are you to recommend [Company]?\",
\"from_email_id\": 10001,
\"highlight_color\": \"#77a500\",
\"intro_text\": \"Hi Richard, how are you today?\",
\"name\": \"After Purchase Survey\",
\"relationship_id\": 4,
\"subject\": \"Zendesk Support\"
}
}""");
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("PUT", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", Credentials.basic("your-email", "your-password"))
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var data = JSON.stringify({
"survey": {
"comments_question": "Will you let us know why?",
"email_subject": "How likely are you to recommend [Company]?",
"from_email_id": 10001,
"highlight_color": "#77a500",
"intro_text": "Hi Richard, how are you today?",
"name": "After Purchase Survey",
"relationship_id": 4,
"subject": "Zendesk Support"
}
});
var config = {
method: 'PUT',
url: 'https://support.zendesk.com/api/v2/nps/surveys/1234',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic <auth-value>', // Base64 encoded "username:password"
},
data : data,
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python
import requests
import json
url = "https://support.zendesk.com/api/v2/nps/surveys/1234"
payload = json.loads("""{
"survey": {
"comments_question": "Will you let us know why?",
"email_subject": "How likely are you to recommend [Company]?",
"from_email_id": 10001,
"highlight_color": "#77a500",
"intro_text": "Hi Richard, how are you today?",
"name": "After Purchase Survey",
"relationship_id": 4,
"subject": "Zendesk Support"
}
}""")
headers = {
"Content-Type": "application/json",
}
response = requests.request(
"PUT",
url,
auth=('<username>', '<password>'),
headers=headers,
json=payload
)
print(response.text)
Ruby
require "net/http"
uri = URI("https://support.zendesk.com/api/v2/nps/surveys/1234")
request = Net::HTTP::Put.new(uri, "Content-Type": "application/json")
request.body = %q({
"survey": {
"comments_question": "Will you let us know why?",
"email_subject": "How likely are you to recommend [Company]?",
"from_email_id": 10001,
"highlight_color": "#77a500",
"intro_text": "Hi Richard, how are you today?",
"name": "After Purchase Survey",
"relationship_id": 4,
"subject": "Zendesk Support"
}
})
request.basic_auth "username", "password"
response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|
http.request(request)
end
Example response(s)
200 OK
// Status 200 OK
{
"survey": {
"comments_question": "Will you let us know why?",
"created_at": "2020-06-01T00:00:00-07:00",
"delivery_method": "email",
"email_subject": "How likely are you to recommend us?",
"from_email_id": 10001,
"highlight_color": "#77a500",
"id": 1,
"intro_text": "Hi, this is a follow-up to your recent purchase.",
"name": "After Purchase Survey",
"relationship_id": 4,
"status": "open",
"subject": "Zendesk Support",
"updated_at": "2020-06-01T00:00:00-07:00"
}
}
Close Survey
POST /api/v2/nps/surveys/{survey_id}/close
Closes an existing survey.
Allowed for
- Admins
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
survey_id | integer | Path | true | ID of survey. |
Code Samples
curl
curl \
--data '' \
--request POST \
-v -u {email_address}:{password} \
https://{subdomain}.zendesk.com/api/v2/nps/surveys/{survey_id}/close
Go
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://support.zendesk.com/api/v2/nps/surveys/1234/close"
method := "POST"
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "username:password"
client := &http.Client {}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
import com.squareup.okhttp.*;
OkHttpClient client = new OkHttpClient();
HttpUrl.Builder urlBuilder = HttpUrl.parse("https://support.zendesk.com/api/v2/nps/surveys/1234/close")
.newBuilder();
RequestBody body = RequestBody.create(MediaType.parse("application/json"),
"""
""");
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", Credentials.basic("your-email", "your-password"))
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {
method: 'POST',
url: 'https://support.zendesk.com/api/v2/nps/surveys/1234/close',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic <auth-value>', // Base64 encoded "username:password"
},
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python
import requests
url = "https://support.zendesk.com/api/v2/nps/surveys/1234/close"
headers = {
"Content-Type": "application/json",
}
response = requests.request(
"POST",
url,
auth=('<username>', '<password>'),
headers=headers
)
print(response.text)
Ruby
require "net/http"
uri = URI("https://support.zendesk.com/api/v2/nps/surveys/1234/close")
request = Net::HTTP::Post.new(uri, "Content-Type": "application/json")
request.basic_auth "username", "password"
response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|
http.request(request)
end
Example response(s)
200 OK
// Status 200 OK
{
"survey": {
"comments_question": "Will you let us know why?",
"created_at": "2020-06-01T00:00:00-07:00",
"delivery_method": "email",
"email_subject": "How likely are you to recommend us?",
"from_email_id": 10001,
"highlight_color": "#77a500",
"id": 1,
"intro_text": "Hi, this is a follow-up to your recent purchase.",
"name": "After Purchase Survey",
"relationship_id": 4,
"status": "open",
"subject": "Zendesk Support",
"updated_at": "2020-06-01T00:00:00-07:00"
}
}
Preview Survey
GET /api/v2/nps/surveys/{survey_id}/preview?locale={locale}
Previews a survey in a specific locale.
Allowed for
- Admins
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
locale | string | Query | true | Rendered locale for preview. |
survey_id | integer | Path | true | ID of survey. |
Code Samples
curl
curl https://{subdomain}.zendesk.com/api/v2/nps/surveys/{survey_id}/preview.json?locale={locale} \
-v -u {email_address}:{password}
Go
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://support.zendesk.com/api/v2/nps/surveys/1234/preview?locale=en-US"
method := "GET"
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Basic <auth-value>") // Base64 encoded "username:password"
client := &http.Client {}
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
import com.squareup.okhttp.*;
OkHttpClient client = new OkHttpClient();
HttpUrl.Builder urlBuilder = HttpUrl.parse("https://support.zendesk.com/api/v2/nps/surveys/1234/preview")
.newBuilder()
.addQueryParameter("locale", "en-US");
Request request = new Request.Builder()
.url(urlBuilder.build())
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", Credentials.basic("your-email", "your-password"))
.build();
Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {
method: 'GET',
url: 'https://support.zendesk.com/api/v2/nps/surveys/1234/preview',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Basic <auth-value>', // Base64 encoded "username:password"
},
params: {
'locale': 'en-US',
},
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python
import requests
url = "https://support.zendesk.com/api/v2/nps/surveys/1234/preview?locale=en-US"
headers = {
"Content-Type": "application/json",
}
response = requests.request(
"GET",
url,
auth=('<username>', '<password>'),
headers=headers
)
print(response.text)
Ruby
require "net/http"
uri = URI("https://support.zendesk.com/api/v2/nps/surveys/1234/preview")
uri.query = URI.encode_www_form("locale": "en-US")
request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")
request.basic_auth "username", "password"
response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|
http.request(request)
end
Example response(s)
200 OK
// Status 200 OK
{
"survey_preview": {
"comments_question": "Will you let us know why?",
"feedback_placeholder": "Write your comment here...",
"highlight_color": "#77a500",
"id": 1,
"likely_label": "Extremely likely",
"logo_url": "http://example.com/logo.jpg",
"not_likely_label": "Not at all likely",
"question": "How likely are you to recommend Zendesk Support to someone you know?",
"status": "open",
"thank_you": "Thank you for your feedback.",
"you_rated": "You rated us a %{rating}"
}
}