Resource Collections
A resource collection consists of Zendesk Support resource definitions. For example, a resource collection could define two different targets and one ticket field. You specify the resource collection the same way you specify theresource requirementsfor a Zendesk app.
Resource objects
TheList Resource CollectionsandShow Resource Collectionendpoints return a亚博电脑端
array. Each object in the亚博电脑端
array contains metadata for a resource in a resource collection.
Objects in the亚博电脑端
array have the following properties:
Name | Type | Read-only | Mandatory | Description |
---|---|---|---|---|
identifier | string | true | false | Descriptive name for the resource |
resource_id | integer | true | false | Unique id for the resource. Automatically assigned upon creation |
type | array | true | false | Resource type. Possible values are "automations", "channel_integrations", "custom_objects", "macros", "organization_fields", "targets", "ticket_fields", "triggers", "user_fields", "view", and "webhooks" |
deleted | boolean | true | false | If true, the resource has been deleted |
JSON format
Resource Collections are represented as JSON objects with the following properties:
Name | Type | Read-only | Mandatory | Description |
---|---|---|---|---|
created_at | string | true | false | When the resource collection was created |
id | integer | true | false | id for the resource collection. Automatically assigned upon creation |
亚博电脑端 | array | true | false | Array of resource metadata objects. SeeResource objects |
updated_at | string | true | false | Last time the resource collection was updated |
Example
{
"created_at":"2011-07-20T22:55:29Z",
"id":35436,
"resources":[
{
"deleted":false,
"identifier":"email_on_ticket_solved",
"resource_id":10824486485524,
"type":"triggers"
},
{
"deleted":false,
"identifier":"support_description",
"resource_id":10824486482580,
"type":"ticket_fields"
}
],
"updated_at":"2011-07-20T22:55:29Z"
}
List Resource Collections
GET /api/v2/resource_collections
Lists resource collections for the account.
Allowed for
- Admins
代码示例
curl
curlhttps://{subdomain}.zendesk.com/api/v2/resource_collections.json\
-v -u{email_address}:{password}
Go
import(
"fmt"
"io"
"net/http"
)
funcmain(){
url:="https://example.zendesk.com/api/v2/resource_collections"
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://example.zendesk.com/api/v2/resource_collections")
.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://example.zendesk.com/api/v2/resource_collections',
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://example.zendesk.com/api/v2/resource_collections"
headers={
"Content-Type":"application/json",
}
response=requests.request(
"GET",
url,
auth=('
' ,'' ),headers=headers
)
print(response.text)
Ruby
require"net/http"
uri=URI("https://example.zendesk.com/api/v2/resource_collections")
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
{
"count":0,
"next_page":null,
"previous_page":null,
"resource_collections":[
{
"created_at":"2015-09-09T01:57:24Z",
"id":10002,
"resources":[
{
"deleted":false,
"identifier":"email_on_ticket_solved",
"resource_id":10824486485524,
"type":"triggers"
},
{
"deleted":false,
"identifier":"support_description",
"resource_id":10824486482580,
"type":"ticket_fields"
}
],
"updated_at":"2015-09-09T01:57:24Z"
},
{
"created_at":"2015-09-10T02:01:03Z",
"id":10002,
"resources":[
{
"deleted":false,
"identifier":"an_email_target",
"resource_id":10827267902996,
"type":"targets"
}
],
"updated_at":"2015-09-10T02:02:15Z"
}
]
}
Show Resource Collection
GET /api/v2/resource_collections/{resource_collection_id}
Retrieves details for a specified resource collection.
Allowed for
- Admins
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
resource_collection_id | integer | Path | true | The id of the resource collection |
代码示例
curl
curlhttps://{subdomain}.zendesk.com/api/v2/resource_collections/{resource_collection_id}.json\
-v -u{email_address}:{password}
Go
import(
"fmt"
"io"
"net/http"
)
funcmain(){
url:="https://example.zendesk.com/api/v2/resource_collections/10002"
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://example.zendesk.com/api/v2/resource_collections/10002")
.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://example.zendesk.com/api/v2/resource_collections/10002',
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://example.zendesk.com/api/v2/resource_collections/10002"
headers={
"Content-Type":"application/json",
}
response=requests.request(
"GET",
url,
auth=('
' ,'' ),headers=headers
)
print(response.text)
Ruby
require"net/http"
uri=URI("https://example.zendesk.com/api/v2/resource_collections/10002")
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
{
"resource_collection":{
"created_at":"2015-09-09T01:57:24Z",
"id":10002,
"resources":[
{
"deleted":false,
"identifier":"email_on_ticket_solved",
"resource_id":10824486485524,
"type":"triggers"
},
{
"deleted":false,
"identifier":"support_description",
"resource_id":10824486482580,
"type":"ticket_fields"
}
],
"updated_at":"2015-09-09T01:57:24Z"
}
}
Create Resource Collection
POST /api/v2/resource_collections
Creates a resource collection from a providedpayload
object. Thepayload
object is specified the same way as the content of a requirements.json file in a Zendesk app. SeeSpecifying Apps Requirementsin the Zendesk Apps framework docs.
The response includes ajob statusfor creation of the specified resources.
Allowed for
- Admins
代码示例
curl
curlhttps://{subdomain}.zendesk.com/api/v2/resource_collections.json\
-v -u{email_address}:{password}-X POST\
-H"Content-Type: application/json"\
-d'{
"payload": {
"ticket_fields": {
"support_description": {
"type": "text",
"title": "Support description"
}
},
"triggers": {
"email_on_ticket_solved": {
"title": "Email on ticket solved Trigger",
"all": [
{
"field": "status",
"operator": "is",
"value": "solved"
}
],
"actions": [
{
"field": "notification_user",
"value": [
"all_agents",
"[{{ticket.account}}] {{ticket.title}}",
"A ticket (#{{ticket.id}}) by {{ticket.requester.name}} has been received. It is unassigned.\n\n{{ticket.comments_formatted}}"
]
}
]
}
}
}
}'
Go
import(
"fmt"
"io"
"net/http"
)
funcmain(){
url:="https://example.zendesk.com/api/v2/resource_collections"
method:="POST"
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://example.zendesk.com/api/v2/resource_collections")
.newBuilder();
RequestBodybody=RequestBody.create(MediaType.parse("application/json"),
"""
""");
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');
varconfig={
method:'POST',
url:'https://example.zendesk.com/api/v2/resource_collections',
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://example.zendesk.com/api/v2/resource_collections"
headers={
"Content-Type":"application/json",
}
response=requests.request(
"POST",
url,
auth=('
' ,'' ),headers=headers
)
print(response.text)
Ruby
require"net/http"
uri=URI("https://example.zendesk.com/api/v2/resource_collections")
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:truedo|http|
http.request(request)
end
Example response(s)
200 OK
// Status 200 OK
{
"job_status":{
"id":"0a3e49b038c40133d7380242ac110031",
"message":null,
"progress":null,
"results":null,
“状态”:"queued",
"total":null,
"url":"https://company.zendesk.com/api/v2/job_statuses/0a3e49b038c40133d7380242ac110031.json"
}
}
Update Resource Collection
PUT /api/v2/resource_collections/{resource_collection_id}
Updates a resource collection using a providedpayload
object. Thepayload
object is specified the same way as the content of a requirements.json file in a Zendesk app. SeeSpecifying Apps Requirementsin the Zendesk Apps framework docs.
The response includes ajob statusfor the resource updates.
Allowed for
- Admins
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
resource_collection_id | integer | Path | true | The id of the resource collection |
代码示例
curl
curlhttps://{subdomain}.zendesk.com/api/v2/resource_collections/{resource_collection_id}.json\
-v -u{email_address}:{password}-X PUT\
-H"Content-Type: application/json"\
-d'{
"payload": {
"targets": {
"an_email_target": {
"title": "Send notification email",
"type": "email_target",
"email": "[email protected]",
"subject": "Hey, something happened!"
}
}
}
}'
Go
import(
"fmt"
"io"
"net/http"
)
funcmain(){
url:="https://example.zendesk.com/api/v2/resource_collections/10002"
method:="PUT"
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://example.zendesk.com/api/v2/resource_collections/10002")
.newBuilder();
RequestBodybody=RequestBody.create(MediaType.parse("application/json"),
"""
""");
Requestrequest=newRequest.Builder()
.url(urlBuilder.build())
.method("PUT",body)
.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:'PUT',
url:'https://example.zendesk.com/api/v2/resource_collections/10002',
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://example.zendesk.com/api/v2/resource_collections/10002"
headers={
"Content-Type":"application/json",
}
response=requests.request(
"PUT",
url,
auth=('
' ,'' ),headers=headers
)
print(response.text)
Ruby
require"net/http"
uri=URI("https://example.zendesk.com/api/v2/resource_collections/10002")
request=Net::HTTP::Put.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
{
"job_status":{
"id":"4555831038d20133d7390242ac110031",
"message":null,
"progress":null,
"results":null,
“状态”:"queued",
"total":null,
"url":"https://company.zendesk.com/api/v2/job_statuses/4555831038d20133d7390242ac110031.json"
}
}
删除Resource Collection
DELETE /api/v2/resource_collections/{resource_collection_id}
删除s a specified resource collection.
The response includes ajob statusfor deletion of the collection's resources.
Allowed for
- Admins
Parameters
Name | Type | In | Required | Description |
---|---|---|---|---|
resource_collection_id | integer | Path | true | The id of the resource collection |
代码示例
curl
curlhttps://{subdomain}.zendesk.com/api/v2/resource_collections/{resource_collection_id}.json\
-v -u{email_address}:{password}-X DELETE
Go
import(
"fmt"
"io"
"net/http"
)
funcmain(){
url:="https://example.zendesk.com/api/v2/resource_collections/10002"
method:="DELETE"
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://example.zendesk.com/api/v2/resource_collections/10002")
.newBuilder();
Requestrequest=newRequest.Builder()
.url(urlBuilder.build())
.method("DELETE",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:'DELETE',
url:'https://example.zendesk.com/api/v2/resource_collections/10002',
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://example.zendesk.com/api/v2/resource_collections/10002"
headers={
"Content-Type":"application/json",
}
response=requests.request(
"DELETE",
url,
auth=('
' ,'' ),headers=headers
)
print(response.text)
Ruby
require"net/http"
uri=URI("https://example.zendesk.com/api/v2/resource_collections/10002")
request=Net::HTTP::删除.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
{
"job_status":{
"id":"2ee570d0398e0133e26e0242ac110017",
"message":null,
"progress":null,
"results":null,
“状态”:"queued",
"total":null,
"url":"https://company.zendesk.com/api/v2/job_statuses/2ee570d0398e0133e26e0242ac110017.json"
}
}