Organization Subscriptions
Agents in an organization can subscribe to be notified whenever someone in their organization submits a ticket. The agents will be notified as long as they're allowed to see all tickets or the organization's tickets. SeeSetting agent privileges and defining ticket accessin the Zendesk Support knowledge base.
最终用户can also subscribe to be notified if they're members of a shared organization. SeeSetting up a shared organization for end-usersandViewing and editing a user's profilein the knowledge base.
JSON format
Organization Subscriptions are represented as JSON objects with the following properties:
Name | Type | Read-only | 强制性的 | Description |
---|---|---|---|---|
created_at | string | false | false | The date the organization subscription was created |
id | integer | false | false | The ID of the organization subscription |
organization_id | integer | false | false | The ID of the organization |
user_id | integer | false | false | The ID of the user |
Example
{
"created_at":"2009-07-20T22:55:29Z",
"id":1234,
"organization_id":32,
"user_id":482
}
List Organization Subscriptions
GET /api/v2/organization_subscriptions
GET /api/v2/organizations/{organization_id}/subscriptions
GET /api/v2/users/{user_id}/organization_subscriptions
Pagination
- Cursor pagination (recommended)
- Offset pagination
SeePagination.
Returns a maximum of 100 records per page.
允许:
- Agents
- 最终用户
For end users, the response will only list the subscriptions created by the requesting end user.
Code Samples
cURL
旋度https://{subdomain}.zendesk.com/api/v2/organization_subscriptions.json\
-v -u{email_address}:{password}
Go
import(
"fmt"
"io"
"net/http"
)
funcmain(){
url:="https://example.zendesk.com/api/v2/organization_subscriptions"
method:="GET"
req,err:=http.NewRequest(method,url,nil)
iferr!=nil{
fmt.Println(err)
return
}
req.Header.Add(“内容类型”,"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://example.zendesk.com/api/v2/organization_subscriptions")
.newBuilder();
Request请求=newRequest.Builder()
.url(urlBuilder.build())
.method("GET",null)
.addHeader(“内容类型”,"application/json")
.addHeader("Authorization",Credentials.基本("your-email","your-password"))
.build();
Responseresponse=client.newCall(请求).execute();
Nodejs
varaxios=require('axios');
varconfig={
method:'GET',
url:'https://example.zendesk.com/api/v2/organization_subscriptions',
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
import请求s
url="https://example.zendesk.com/api/v2/organization_subscriptions"
headers={
“内容类型”:"application/json",
}
response=请求s.请求(
"GET",
url,
auth=('
' ,'' ),headers=headers
)
print(response.text)
Ruby
require"net/http"
uri=URI("https://example.zendesk.com/api/v2/organization_subscriptions")
请求=Net::HTTP::Get.new(uri,“内容类型”:"application/json")
请求.基本_auth"username","password"
response=Net::HTTP.start uri.hostname,uri.port,use_ssl:truedo|http|
http.请求(请求)
end
Example response(s)
200 OK
// Status 200 OK
{
"organization_subscriptions":[
{
"created_at":"2009-07-20T22:55:29Z",
"id":1234,
"organization_id":32,
"user_id":482
},
{
"created_at":"2011-08-22T21:12:09Z",
"id":43681,
"organization_id":334,
"user_id":49471
}
]
}
Show Organization Subscription
GET /api/v2/organization_subscriptions/{organization_subscription_id}
允许:
- Agents
- 最终用户
For end users, the response will only list the subscriptions created by the requesting end user.
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
organization_subscription_id | integer | Path | true | The ID of the organization subscription |
Code Samples
cURL
旋度https://{subdomain}.zendesk.com/api/v2/organization_subscriptions/{organization_subscription_id}.json\
-v -u{email_address}:{password}
Go
import(
"fmt"
"io"
"net/http"
)
funcmain(){
url:="https://example.zendesk.com/api/v2/organization_subscriptions/35436"
method:="GET"
req,err:=http.NewRequest(method,url,nil)
iferr!=nil{
fmt.Println(err)
return
}
req.Header.Add(“内容类型”,"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://example.zendesk.com/api/v2/organization_subscriptions/35436")
.newBuilder();
Request请求=newRequest.Builder()
.url(urlBuilder.build())
.method("GET",null)
.addHeader(“内容类型”,"application/json")
.addHeader("Authorization",Credentials.基本("your-email","your-password"))
.build();
Responseresponse=client.newCall(请求).execute();
Nodejs
varaxios=require('axios');
varconfig={
method:'GET',
url:'https://example.zendesk.com/api/v2/organization_subscriptions/35436',
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
import请求s
url="https://example.zendesk.com/api/v2/organization_subscriptions/35436"
headers={
“内容类型”:"application/json",
}
response=请求s.请求(
"GET",
url,
auth=('
' ,'' ),headers=headers
)
print(response.text)
Ruby
require"net/http"
uri=URI("https://example.zendesk.com/api/v2/organization_subscriptions/35436")
请求=Net::HTTP::Get.new(uri,“内容类型”:"application/json")
请求.基本_auth"username","password"
response=Net::HTTP.start uri.hostname,uri.port,use_ssl:truedo|http|
http.请求(请求)
end
Example response(s)
200 OK
// Status 200 OK
{
"organization_subscription":{
"created_at":"2009-07-20T22:55:29Z",
"id":1234,
"organization_id":32,
"user_id":482
}
}
Create Organization Subscription
POST /api/v2/organization_subscriptions
允许:
- Agents
- 最终用户
最终用户can only subscribe to shared organizations in which they're members.
Example body
{
"organization_subscription":{
"organization_id":32,
"user_id":482
}
}
Code Samples
cURL
旋度https://{subdomain}.zendesk.com/api/v2/organization_subscriptions.json\
-d'{"organization_subscription": {"user_id": 772, "organization_id": 881}}'\
-v -u{email_address}:{password}- h"Content-Type: application/json"-X POST
Go
import(
"fmt"
"io"
"net/http"
"strings"
)
funcmain(){
url:="https://example.zendesk.com/api/v2/organization_subscriptions"
method:="POST"
payload:=strings.NewReader(`{
"organization_subscription": {
"organization_id": 32,
"user_id": 482
}
}`)
req,err:=http.NewRequest(method,url,payload)
iferr!=nil{
fmt.Println(err)
return
}
req.Header.Add(“内容类型”,"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://example.zendesk.com/api/v2/organization_subscriptions")
.newBuilder();
RequestBodybody=RequestBody.create(MediaType.parse("application/json"),
"""
{
\"organization_subscription\":{
\"organization_id\":32,
\"user_id\":482
}
}""");
Request请求=newRequest.Builder()
.url(urlBuilder.build())
.method("POST",body)
.addHeader(“内容类型”,"application/json")
.addHeader("Authorization",Credentials.基本("your-email","your-password"))
.build();
Responseresponse=client.newCall(请求).execute();
Nodejs
varaxios=require('axios');
vardata=JSON.stringify({
"organization_subscription":{
"organization_id":32,
"user_id":482
}
});
varconfig={
method:'POST',
url:'https://example.zendesk.com/api/v2/organization_subscriptions',
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
import请求s
importjson
url="https://example.zendesk.com/api/v2/organization_subscriptions"
payload=json.loads("""{
"organization_subscription": {
"organization_id": 32,
"user_id": 482
}
}""")
headers={
“内容类型”:"application/json",
}
response=请求s.请求(
"POST",
url,
auth=('
' ,'' ),headers=headers,
json=payload
)
print(response.text)
Ruby
require"net/http"
uri=URI("https://example.zendesk.com/api/v2/organization_subscriptions")
请求=Net::HTTP::Post.new(uri,“内容类型”:"application/json")
请求.body=%q({
"organization_subscription":{
"organization_id":32,
"user_id":482
}
})
请求.基本_auth"username","password"
response=Net::HTTP.start uri.hostname,uri.port,use_ssl:truedo|http|
http.请求(请求)
end
Example response(s)
200 OK
// Status 200 OK
{
"organization_subscription":{
"created_at":"2009-07-20T22:55:29Z",
"id":1234,
"organization_id":32,
"user_id":482
}
}
删除Organization Subscription
DELETE /api/v2/organization_subscriptions/{organization_subscription_id}
允许:
- Agents
- 最终用户
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
organization_subscription_id | integer | Path | true | The ID of the organization subscription |
Code Samples
cURL
旋度https://{subdomain}.zendesk.com/api/v2/organization_subscriptions/{organization_subscription_id}.json\
-v -u{email_address}:{password}-X DELETE
Go
import(
"fmt"
"io"
"net/http"
)
funcmain(){
url:="https://example.zendesk.com/api/v2/organization_subscriptions/35436"
method:="DELETE"
req,err:=http.NewRequest(method,url,nil)
iferr!=nil{
fmt.Println(err)
return
}
req.Header.Add(“内容类型”,"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://example.zendesk.com/api/v2/organization_subscriptions/35436")
.newBuilder();
Request请求=newRequest.Builder()
.url(urlBuilder.build())
.method("DELETE",null)
.addHeader(“内容类型”,"application/json")
.addHeader("Authorization",Credentials.基本("your-email","your-password"))
.build();
Responseresponse=client.newCall(请求).execute();
Nodejs
varaxios=require('axios');
varconfig={
method:'DELETE',
url:'https://example.zendesk.com/api/v2/organization_subscriptions/35436',
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
import请求s
url="https://example.zendesk.com/api/v2/organization_subscriptions/35436"
headers={
“内容类型”:"application/json",
}
response=请求s.请求(
"DELETE",
url,
auth=('
' ,'' ),headers=headers
)
print(response.text)
Ruby
require"net/http"
uri=URI("https://example.zendesk.com/api/v2/organization_subscriptions/35436")
请求=Net::HTTP::删除.new(uri,“内容类型”:"application/json")
请求.基本_auth"username","password"
response=Net::HTTP.start uri.hostname,uri.port,use_ssl:truedo|http|
http.请求(请求)
end
Example response(s)
204 No Content
// Status 204 No Content
null