API to manage capacity rules

JSON format

Capacity Rules API are represented as JSON objects with the following properties:

NameTypeRead-onlyMandatoryDescription
assigneesobjectfalsefalseSubset of assignees that are part of the capacity rule
capacitiesobjectfalsefalseList of the rule's capacities per channel
created_atstringfalsefalseWhen the capacity rule was created
defaultbooleanfalsefalseTrue for the account's default capacity rule. Otherwise false
descriptionstringfalsefalseDescription of the capacity rule
idstringfalsefalseAutomatically assigned when the capacity rule is created
last_updated_atstringfalsefalseWhen the capacity rule was last updated
namestringfalsefalseName of the capacity rule

List Capacity Rules

  • GET /api/v2/capacity/rules

Returns all capacity rules in the account.

Allowed For

  • Admins

Code Samples

Curl
curl --request GET https://support.zendesk.com/api/v2/capacity/rules \--header "Content-Type: application/json" \-u {email_address}/token:{api_token}
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://support.zendesk.com/api/v2/capacity/rules"	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 "{email_address}/token:{api_token}"
	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/capacity/rules")		.newBuilder();String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());
Request request = new Request.Builder()		.url(urlBuilder.build())		.method("GET", null)		.addHeader("Content-Type", "application/json")		.addHeader("Authorization", basicAuth)		.build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {  method: 'GET',  url: 'https://support.zendesk.com/api/v2/capacity/rules',  headers: {	'Content-Type': 'application/json',	'Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"  },};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuth
url = "https://support.zendesk.com/api/v2/capacity/rules"headers = {	"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)
response = requests.request(	"GET",	url,	auth=auth,	headers=headers)
print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://support.zendesk.com/api/v2/capacity/rules")request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"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
[  {    "assignees": {      "agents_sample": [        {          "id": 123,          "name": "[email protected]"        },        {          "id": 456,          "name": "[email protected]"        }      ],      "count": 2    },    "capacities": {      "email": 1,      "messaging": 0,      "voice": 0    },    "created_at": "2022-01-01T00:00:00.000Z",    "default": false,    "description": "Example description",    "id": "12345678901234567890123456",    "last_updated_at": "2023-01-01T00:00:00.000Z",    "name": "Example capacity rule"  }]
400 Bad Request
// Status 400 Bad Request
{  "error": "Example error message"}

Create Capacity Rule

  • POST /api/v2/capacity/rules

Create a new capacity rule.

Allowed For

  • Admins

Example body

{  "agent_ids": [    123,    456  ],  "capacities": {    "email": 2,    "messaging": 1,    "voice": 0  },  "default": false,  "description": "Example description",  "name": "Example capacity rule"}

Code Samples

Curl
curl --request POST https://support.zendesk.com/api/v2/capacity/rules \--header "Content-Type: application/json" \-u {email_address}/token:{api_token} \--data-raw '{  "agent_ids": [    123,    456  ],  "capacities": {    "email": 2,    "messaging": 1,    "voice": 0  },  "default": false,  "description": "Example description",  "name": "Example capacity rule"}'
Go
import (	"fmt"	"io"	"net/http"	"strings")
func main() {	url := "https://support.zendesk.com/api/v2/capacity/rules"	method := "POST"	payload := strings.NewReader(`{  "agent_ids": [    123,    456  ],  "capacities": {    "email": 2,    "messaging": 1,    "voice": 0  },  "default": false,  "description": "Example description",  "name": "Example capacity rule"}`)	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 "{email_address}/token:{api_token}"
	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/capacity/rules")		.newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),		"""{  \"agent_ids\": [    123,    456  ],  \"capacities\": {    \"email\": 2,    \"messaging\": 1,    \"voice\": 0  },  \"default\": false,  \"description\": \"Example description\",  \"name\": \"Example capacity rule\"}""");String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());
Request request = new Request.Builder()		.url(urlBuilder.build())		.method("POST", body)		.addHeader("Content-Type", "application/json")		.addHeader("Authorization", basicAuth)		.build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var data = JSON.stringify({  "agent_ids": [    123,    456  ],  "capacities": {    "email": 2,    "messaging": 1,    "voice": 0  },  "default": false,  "description": "Example description",  "name": "Example capacity rule"});
var config = {  method: 'POST',  url: 'https://support.zendesk.com/api/v2/capacity/rules',  headers: {	'Content-Type': 'application/json',	'Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"  },  data : data,};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requestsimport jsonfrom requests.auth import HTTPBasicAuth
url = "https://support.zendesk.com/api/v2/capacity/rules"
payload = json.loads("""{  "agent_ids": [    123,    456  ],  "capacities": {    "email": 2,    "messaging": 1,    "voice": 0  },  "default": false,  "description": "Example description",  "name": "Example capacity rule"}""")headers = {	"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)
response = requests.request(	"POST",	url,	auth=auth,	headers=headers,	json=payload)
print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://support.zendesk.com/api/v2/capacity/rules")request = Net::HTTP::Post.new(uri, "Content-Type": "application/json")request.body = %q({  "agent_ids": [    123,    456  ],  "capacities": {    "email": 2,    "messaging": 1,    "voice": 0  },  "default": false,  "description": "Example description",  "name": "Example capacity rule"})email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"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
{  "assignees": {    "agents_sample": [      {        "id": 123,        "name": "[email protected]"      },      {        "id": 456,        "name": "[email protected]"      }    ],    "count": 2  },  "capacities": {    "email": 1,    "messaging": 0,    "voice": 0  },  "created_at": "2022-01-01T00:00:00.000Z",  "default": false,  "description": "Example description",  "id": "12345678901234567890123456",  "last_updated_at": "2023-01-01T00:00:00.000Z",  "name": "Example capacity rule"}
400 Bad Request
// Status 400 Bad Request
{  "error": "Example error message"}

Show Capacity Rule

  • GET /api/v2/capacity/rules/{capacity_rule_id}

Returns capacity rule by id.

Allowed For

  • Admins

Parameters

NameTypeInRequiredDescription
capacity_rule_idstringPathtrueCapacity rule id

Code Samples

Curl
curl --request GET https://support.zendesk.com/api/v2/capacity/rules/12345678901234567890123456 \--header "Content-Type: application/json" \-u {email_address}/token:{api_token}
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://support.zendesk.com/api/v2/capacity/rules/12345678901234567890123456"	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 "{email_address}/token:{api_token}"
	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/capacity/rules/12345678901234567890123456")		.newBuilder();String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());
Request request = new Request.Builder()		.url(urlBuilder.build())		.method("GET", null)		.addHeader("Content-Type", "application/json")		.addHeader("Authorization", basicAuth)		.build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {  method: 'GET',  url: 'https://support.zendesk.com/api/v2/capacity/rules/12345678901234567890123456',  headers: {	'Content-Type': 'application/json',	'Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"  },};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuth
url = "https://support.zendesk.com/api/v2/capacity/rules/12345678901234567890123456"headers = {	"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)
response = requests.request(	"GET",	url,	auth=auth,	headers=headers)
print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://support.zendesk.com/api/v2/capacity/rules/12345678901234567890123456")request = Net::HTTP::Get.new(uri, "Content-Type": "application/json")email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"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
{  "assignees": {    "agents_sample": [      {        "id": 123,        "name": "[email protected]"      },      {        "id": 456,        "name": "[email protected]"      }    ],    "count": 2  },  "capacities": {    "email": 1,    "messaging": 0,    "voice": 0  },  "created_at": "2022-01-01T00:00:00.000Z",  "default": false,  "description": "Example description",  "id": "12345678901234567890123456",  "last_updated_at": "2023-01-01T00:00:00.000Z",  "name": "Example capacity rule"}
400 Bad Request
// Status 400 Bad Request
{  "error": "Example error message"}
404 Not Found
// Status 404 Not Found
{  "error": "Example error message"}

Update Capacity Rule

  • PUT /api/v2/capacity/rules/{capacity_rule_id}

Update capacity rule by id.

Allowed For

  • Admins

Parameters

NameTypeInRequiredDescription
capacity_rule_idstringPathtrueCapacity rule id

Example body

{  "agent_ids": [    123,    456  ],  "capacities": {    "email": 2,    "messaging": 1,    "voice": 0  },  "default": false,  "description": "Example description",  "name": "Example capacity rule"}

Code Samples

Curl
curl --request PUT https://support.zendesk.com/api/v2/capacity/rules/12345678901234567890123456 \--header "Content-Type: application/json" \-u {email_address}/token:{api_token} \--data-raw '{  "agent_ids": [    123,    456  ],  "capacities": {    "email": 2,    "messaging": 1,    "voice": 0  },  "default": false,  "description": "Example description",  "name": "Example capacity rule"}'
Go
import (	"fmt"	"io"	"net/http"	"strings")
func main() {	url := "https://support.zendesk.com/api/v2/capacity/rules/12345678901234567890123456"	method := "PUT"	payload := strings.NewReader(`{  "agent_ids": [    123,    456  ],  "capacities": {    "email": 2,    "messaging": 1,    "voice": 0  },  "default": false,  "description": "Example description",  "name": "Example capacity rule"}`)	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 "{email_address}/token:{api_token}"
	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/capacity/rules/12345678901234567890123456")		.newBuilder();RequestBody body = RequestBody.create(MediaType.parse("application/json"),		"""{  \"agent_ids\": [    123,    456  ],  \"capacities\": {    \"email\": 2,    \"messaging\": 1,    \"voice\": 0  },  \"default\": false,  \"description\": \"Example description\",  \"name\": \"Example capacity rule\"}""");String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());
Request request = new Request.Builder()		.url(urlBuilder.build())		.method("PUT", body)		.addHeader("Content-Type", "application/json")		.addHeader("Authorization", basicAuth)		.build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');var data = JSON.stringify({  "agent_ids": [    123,    456  ],  "capacities": {    "email": 2,    "messaging": 1,    "voice": 0  },  "default": false,  "description": "Example description",  "name": "Example capacity rule"});
var config = {  method: 'PUT',  url: 'https://support.zendesk.com/api/v2/capacity/rules/12345678901234567890123456',  headers: {	'Content-Type': 'application/json',	'Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"  },  data : data,};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requestsimport jsonfrom requests.auth import HTTPBasicAuth
url = "https://support.zendesk.com/api/v2/capacity/rules/12345678901234567890123456"
payload = json.loads("""{  "agent_ids": [    123,    456  ],  "capacities": {    "email": 2,    "messaging": 1,    "voice": 0  },  "default": false,  "description": "Example description",  "name": "Example capacity rule"}""")headers = {	"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)
response = requests.request(	"PUT",	url,	auth=auth,	headers=headers,	json=payload)
print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://support.zendesk.com/api/v2/capacity/rules/12345678901234567890123456")request = Net::HTTP::Put.new(uri, "Content-Type": "application/json")request.body = %q({  "agent_ids": [    123,    456  ],  "capacities": {    "email": 2,    "messaging": 1,    "voice": 0  },  "default": false,  "description": "Example description",  "name": "Example capacity rule"})email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"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
{  "assignees": {    "agents_sample": [      {        "id": 123,        "name": "[email protected]"      },      {        "id": 456,        "name": "[email protected]"      }    ],    "count": 2  },  "capacities": {    "email": 1,    "messaging": 0,    "voice": 0  },  "created_at": "2022-01-01T00:00:00.000Z",  "default": false,  "description": "Example description",  "id": "12345678901234567890123456",  "last_updated_at": "2023-01-01T00:00:00.000Z",  "name": "Example capacity rule"}
400 Bad Request
// Status 400 Bad Request
{  "error": "Example error message"}
404 Not Found
// Status 404 Not Found
{  "error": "Example error message"}

Delete Capacity Rule

  • DELETE /api/v2/capacity/rules/{capacity_rule_id}

Delete capacity rule by id.

Allowed For

  • Admins

Parameters

NameTypeInRequiredDescription
capacity_rule_idstringPathtrueCapacity rule id

Code Samples

Curl
curl --request DELETE https://support.zendesk.com/api/v2/capacity/rules/12345678901234567890123456 \--header "Content-Type: application/json" \-u {email_address}/token:{api_token}
Go
import (	"fmt"	"io"	"net/http")
func main() {	url := "https://support.zendesk.com/api/v2/capacity/rules/12345678901234567890123456"	method := "DELETE"	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 "{email_address}/token:{api_token}"
	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/capacity/rules/12345678901234567890123456")		.newBuilder();String userCredentials = "your_email_address" + "/token:" + "your_api_token";String basicAuth = "Basic " + java.util.Base64.getEncoder().encodeToString(userCredentials.getBytes());
Request request = new Request.Builder()		.url(urlBuilder.build())		.method("DELETE", null)		.addHeader("Content-Type", "application/json")		.addHeader("Authorization", basicAuth)		.build();Response response = client.newCall(request).execute();
Nodejs
var axios = require('axios');
var config = {  method: 'DELETE',  url: 'https://support.zendesk.com/api/v2/capacity/rules/12345678901234567890123456',  headers: {	'Content-Type': 'application/json',	'Authorization': 'Basic <auth-value>', // Base64 encoded "{email_address}/token:{api_token}"  },};
axios(config).then(function (response) {  console.log(JSON.stringify(response.data));}).catch(function (error) {  console.log(error);});
Python
import requestsfrom requests.auth import HTTPBasicAuth
url = "https://support.zendesk.com/api/v2/capacity/rules/12345678901234567890123456"headers = {	"Content-Type": "application/json",}email_address = 'your_email_address'api_token = 'your_api_token'# Use basic authenticationauth = HTTPBasicAuth(f'{email_address}/token', api_token)
response = requests.request(	"DELETE",	url,	auth=auth,	headers=headers)
print(response.text)
Ruby
require "net/http"require "base64"uri = URI("https://support.zendesk.com/api/v2/capacity/rules/12345678901234567890123456")request = Net::HTTP::Delete.new(uri, "Content-Type": "application/json")email = "your_email_address"api_token = "your_api_token"credentials = "#{email}/token:#{api_token}"encoded_credentials = Base64.strict_encode64(credentials)request["Authorization"] = "Basic #{encoded_credentials}"response = Net::HTTP.start uri.hostname, uri.port, use_ssl: true do |http|	http.request(request)end

Example response(s)

204 No Content
// Status 204 No Content
null
400 Bad Request
// Status 400 Bad Request
{  "error": "Example error message"}
404 Not Found
// Status 404 Not Found
{  "error": "Example error message"}