NPS® Invitations
Note:This API endpoint is deprecated. Zendesk is removing Net Promoter Score℠ (NPS®) survey functionality on April 30, 2023. For more information, seeAnnouncing the removal of Net Promoter Score (NPS).
你可以向一个或多个reci发送一个邀请pients to take an NPS survey. You can use an API to set up a continuous delivery of NPS survey invites to your defined recipients. Perhaps you want to offer an NPS survey every time a customer makes a purchase, or perhaps you want to offer a survey 30 days after a customer signs up for your service. How you want to serve up an NPS survey to your customers is up to you.
JSON format
Invitations are represented as JSON objects with the following properties:
Name | Type | Read-only | Mandatory | Description |
---|---|---|---|---|
created_at | string | true | false | When the invitation was created. |
delivered_at | string | true | false | When the invitation was delivered. |
id | integer | true | false | Automatically assigned when a survey invitation is created. |
recipients_count | integer | true | false | The number of invitation recipients. |
status | string | true | false | Status of the invitation. Allowed values are "delivered", "failed", "preparing", "scheduled", or "zero_recipients". |
survey_id | integer | true | false | Survey ID associated with the survey invitation - only present for create invitation responses. |
updated_at | string | true | false | When the invitation was last updated. |
Example
{
"created_at":"2014-01-07T10:22:00Z",
"delivered_at":"2014-01-07T17:22:00Z",
"id":1,
"recipients_count":25,
"status":"scheduled",
"updated_at":"2014-01-07T15:02:00Z"
}
List Invitations
GET /api/v2/nps/surveys/{survey_id}/invitations
List all invitations for an existing survey.
Allowed for
- Admins
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
survey_id | integer | Path | true | ID of survey. |
代码的年代amples
旋度
旋度https://{subdomain}.zendesk.com/api/v2/nps/surveys/{survey_id}/invitations.json\
-v -u{email_address}:{password}
Go
import(
"fmt"
"io"
"net/http"
)
funcmain(){
url:="https://support.zendesk.com/api/v2/nps/surveys/1234/invitations"
method:="GET"
req,err:=http.NewRequest(method,url,nil)
iferr!=nil{
fmt.Println(err)
return
}
req.Header.Add("Content-Type","application/json")
req.Header.Add("Authorization","Basic
" )// Base64 encoded "username:password"client:=&http.Client{}
res,err:=client.Do(req)
iferr!=nil{
fmt.Println(err)
return
}
deferres.Body.Close()
body,err:=io.ReadAll(res.Body)
iferr!=nil{
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
importcom.squareup.okhttp.*;
OkHttpClientclient=newOkHttpClient();
HttpUrl.BuilderurlBuilder=HttpUrl.parse("https://support.zendesk.com/api/v2/nps/surveys/1234/invitations")
.newBuilder();
Requestrequest=newRequest.Builder()
.url(urlBuilder.build())
.method("GET",null)
.addHeader("Content-Type","application/json")
.addHeader("Authorization",Credentials.basic("your-email","your-password"))
.build();
Responseresponse=client.newCall(request).execute();
Nodejs
varaxios=require('axios');
varconfig={
method:'GET',
url:'https://support.zendesk.com/api/v2/nps/surveys/1234/invitations',
headers:{
'Content-Type':'application/json',
'Authorization':'Basic
' ,// Base64 encoded "username:password"},
};
axios(config)
.then(function(response){
console.log(JSON.stringify(response.data));
})
.catch(function(error){
console.log(error);
});
Python
importrequests
url="https://support.zendesk.com/api/v2/nps/surveys/1234/invitations"
headers={
"Content-Type":"application/json",
}
response=requests.request(
"GET",
url,
auth=('
' ,'' ),headers=headers
)
print(response.text)
Ruby
require"net/http"
uri=URI("https://support.zendesk.com/api/v2/nps/surveys/1234/invitations")
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:truedo|http|
http.request(request)
end
Example response(s)
200 OK
// Status 200 OK
{
"invitations":[
{
"created_at":"2020-01-07T10:22:00Z",
"delivered_at":"2020-01-07T17:22:00Z",
"id":1,
"recipients_count":20,
"status":"delivered",
"updated_at":"2020-01-07T15:02:00Z"
},
{
"created_at":"2020-01-08T05:12:00Z",
"delivered_at":"2020-01-08T10:32:00Z",
"id":2,
"recipients_count":10,
"status":"delivered",
"updated_at":"2020-01-08T08:10:00Z"
}
]
}
Create Invitation
POST /api/v2/nps/surveys/{survey_id}/invitations
Sends invitations for a survey to a list of recipients.
The POST request takes one parameter, an invitation object that lists the survery recipients when the invitation is created. The array of recipient information includes the name, email, and language (optional). The maximum number of recipients you can be sent is 10000.
Note:422 errors are possible if you make subsequent API requests to add recipients while the first invitations are still being sent out. SeeCreating an NPS Surveyin the Support Help Center.
Allowed for
- Admins
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
survey_id | integer | Path | true | ID of survey. |
Example body
{
“邀请”:{
"recipients":[
{
"email":"[email protected]",
"language":"en-US",
"name":"Peter"
},
{
"email":"[email protected]",
"language":"en-US",
"name":"David"
}
]
}
}
代码的年代amples
旋度
旋度\
--data\
'{"invitation": { \
{"recipients": [ \
{"email": "[email protected]", "language": "en-US", "name": "Jane Doe"}, \
{"email": "[email protected]", "language": "en-US", "name": "Mike Smith"} \
]}
}}'\
--header"Content-Type: application/json"\
--request POST\
https://{subdomain}.zendesk.com/api/v2/nps/surveys/{survey_id}/invitations.json
Go
import(
"fmt"
"io"
"net/http"
"strings"
)
funcmain(){
url:="https://support.zendesk.com/api/v2/nps/surveys/1234/invitations"
method:="POST"
payload:=strings.NewReader(`{
“邀请”: {
"recipients": [
{
"email": "[email protected]",
"language": "en-US",
"name": "Peter"
},
{
"email": "[email protected]",
"language": "en-US",
"name": "David"
}
]
}
}`)
req,err:=http.NewRequest(method,url,payload)
iferr!=nil{
fmt.Println(err)
return
}
req.Header.Add("Content-Type","application/json")
req.Header.Add("Authorization","Basic
" )// Base64 encoded "username:password"client:=&http.Client{}
res,err:=client.Do(req)
iferr!=nil{
fmt.Println(err)
return
}
deferres.Body.Close()
body,err:=io.ReadAll(res.Body)
iferr!=nil{
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
importcom.squareup.okhttp.*;
OkHttpClientclient=newOkHttpClient();
HttpUrl.BuilderurlBuilder=HttpUrl.parse("https://support.zendesk.com/api/v2/nps/surveys/1234/invitations")
.newBuilder();
RequestBodybody=RequestBody.create(MediaType.parse("application/json"),
"""
{
\"invitation\":{
\"recipients\":[
{
\"email\":\"[email protected].com\",
\"language\":\"en-US\",
\"name\":\"Peter\"
},
{
\"email\":\"[email protected].com\",
\"language\":\"en-US\",
\"name\":\"David\"
}
]
}
}""");
Requestrequest=newRequest.Builder()
.url(urlBuilder.build())
.method("POST",body)
.addHeader("Content-Type","application/json")
.addHeader("Authorization",Credentials.basic("your-email","your-password"))
.build();
Responseresponse=client.newCall(request).execute();
Nodejs
varaxios=require('axios');
vardata=JSON.stringify({
“邀请”:{
"recipients":[
{
"email":"[email protected]",
"language":"en-US",
"name":"Peter"
},
{
"email":"[email protected]",
"language":"en-US",
"name":"David"
}
]
}
});
varconfig={
method:'POST',
url:'https://support.zendesk.com/api/v2/nps/surveys/1234/invitations',
headers:{
'Content-Type':'application/json',
'Authorization':'Basic
' ,// Base64 encoded "username:password"},
data:data,
};
axios(config)
.then(function(response){
console.log(JSON.stringify(response.data));
})
.catch(function(error){
console.log(error);
});
Python
importrequests
importjson
url="https://support.zendesk.com/api/v2/nps/surveys/1234/invitations"
payload=json.loads("""{
“邀请”: {
"recipients": [
{
"email": "[email protected]",
"language": "en-US",
"name": "Peter"
},
{
"email": "[email protected]",
"language": "en-US",
"name": "David"
}
]
}
}""")
headers={
"Content-Type":"application/json",
}
response=requests.request(
"POST",
url,
auth=('
' ,'' ),headers=headers,
json=payload
)
print(response.text)
Ruby
require"net/http"
uri=URI("https://support.zendesk.com/api/v2/nps/surveys/1234/invitations")
request=Net::HTTP::Post.new(uri,"Content-Type":"application/json")
request.body=%q({
“邀请”:{
"recipients":[
{
"email":"[email protected]",
"language":"en-US",
"name":"Peter"
},
{
"email":"[email protected]",
"language":"en-US",
"name":"David"
}
]
}
})
request.basic_auth"username","password"
response=Net::HTTP.start uri.hostname,uri.port,use_ssl:truedo|http|
http.request(request)
end
Example response(s)
201 Created
// Status 201 Created
{
“邀请”:{
"created_at":"2020-01-07T10:22:00Z",
"id":1,
"survey_id":1,
"updated_at":"2020-01-07T10:22:00Z"
}
}
Show Invitation
GET /api/v2/nps/surveys/{survey_id}/invitations/{invitation_id}
Shows an existing invitation for a survey.
Allowed for
- Admins
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
invitation_id | integer | Path | true | ID of invitation. |
survey_id | integer | Path | true | ID of survey. |
代码的年代amples
旋度
旋度https://{subdomain}.zendesk.com/api/v2/nps/surveys/{survey_id}/invitations/{invitation_id}.json\
-v -u{email_address}:{password}
Go
import(
"fmt"
"io"
"net/http"
)
funcmain(){
url:="https://support.zendesk.com/api/v2/nps/surveys/1234/invitations/5678"
method:="GET"
req,err:=http.NewRequest(method,url,nil)
iferr!=nil{
fmt.Println(err)
return
}
req.Header.Add("Content-Type","application/json")
req.Header.Add("Authorization","Basic
" )// Base64 encoded "username:password"client:=&http.Client{}
res,err:=client.Do(req)
iferr!=nil{
fmt.Println(err)
return
}
deferres.Body.Close()
body,err:=io.ReadAll(res.Body)
iferr!=nil{
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Java
importcom.squareup.okhttp.*;
OkHttpClientclient=newOkHttpClient();
HttpUrl.BuilderurlBuilder=HttpUrl.parse("https://support.zendesk.com/api/v2/nps/surveys/1234/invitations/5678")
.newBuilder();
Requestrequest=newRequest.Builder()
.url(urlBuilder.build())
.method("GET",null)
.addHeader("Content-Type","application/json")
.addHeader("Authorization",Credentials.basic("your-email","your-password"))
.build();
Responseresponse=client.newCall(request).execute();
Nodejs
varaxios=require('axios');
varconfig={
method:'GET',
url:'https://support.zendesk.com/api/v2/nps/surveys/1234/invitations/5678',
headers:{
'Content-Type':'application/json',
'Authorization':'Basic
' ,// Base64 encoded "username:password"},
};
axios(config)
.then(function(response){
console.log(JSON.stringify(response.data));
})
.catch(function(error){
console.log(error);
});
Python
importrequests
url="https://support.zendesk.com/api/v2/nps/surveys/1234/invitations/5678"
headers={
"Content-Type":"application/json",
}
response=requests.request(
"GET",
url,
auth=('
' ,'' ),headers=headers
)
print(response.text)
Ruby
require"net/http"
uri=URI("https://support.zendesk.com/api/v2/nps/surveys/1234/invitations/5678")
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:truedo|http|
http.request(request)
end
Example response(s)
200 OK
// Status 200 OK
{
“邀请”:{
"created_at":"2020-01-07T10:22:00Z",
"delivered_at":"2020-01-07T17:22:00Z",
"id":1,
"recipients_count":8,
"status":"scheduled",
"updated_at":"2020-01-07T15:02:00Z"
}
}