You can set a schedule in Zendesk to acknowledge your support team's availability and give customers a better sense of when they can expect a personal response to their support requests.

You can use this API to create multiple schedules with different business hours and holidays.

To learn more about schedules, see设置你的日程安排营业时间和胡里节daysin Zendesk help.

JSON format

Schedules are represented as JSON objects with the following properties:

Name Type Read-only Mandatory Description
created_at string true false Time the schedule was created
id integer true false Automatically assigned upon creation
intervals array false false An array of starting and ending times for the schedule. Seeintervals. Writable only whenupdating intervals for a schedule
name string false true Name of the schedule
time_zone string false true Time zone of the schedule
updated_at string true false Time the schedule was last updated

Intervals

Intervals are writable only whenupdating intervals for a schedule. Otherwise, intervals are read-only.

Intervals are represented with the following attributes:

Name Type Comment
start_time integer Integer representation of the interval start time
end_time integer Integer representation of the interval end time

An interval represents an active business-hours period.

Thestart_timeandend_timevalues are expressed as the number of minutes since the start of the week, where Sunday is the first day of the week starting after Saturday's last tick. For instance, Sunday at noon is 720 (12 * 60). The interval in the following example starts Monday at 9 a.m. and ends Tuesday at 5 p.m.

             
{"start_time":1980,"end_time":3900}

The following time table lists minute times during the week to more easily determine start and end times. For example, Friday at 5 p.m. is 5 hours after noon, which can be expressed as 7920 + (5 * 60), or 8220.

Week time Minute time
Sunday midnight 0
Sunday noon 720
Monday midnight 1440
Monday noon 2160
Tuesday midnight 2880
Tuesday noon 3600
Wednesday midnight 4320
Wednesday noon 5040
Thursday midnight 5760
Thursday noon 6480
Friday midnight 7200
Friday noon 7920
Saturday midnight 8640
Saturday noon 9360

The end of the week (Saturday at 23:59) is 10079. A value of 10080 is also accepted for midnight between Saturday and Sunday.

Holidays

Holidays are represented with the following attributes:

Name Type Comment
id integer Automatically assigned upon creation
name string Name of the holiday
start_date string ISO 8601 representation of the holiday start date
end_date string ISO 8601 representation of the holiday end date

Holidays can be a single day or multiple days in length.

Example

             
{"id":1,"name":"New Year's Day 2016","start_time":"2016-01-01","end_time":"2016-01-01"}

Example

             
{"id":1,"intervals":[{"end_time":2460,"start_time":1980},{"end_time":3900,"start_time":3420}],"name":"North America","time_zone":"Pacific Time (US & Canada)"}

List Schedules

  • GET /api/v2/business_hours/schedules

Allowed For

  • Admins

代码示例

curl
              
curlhttps://{subdomain}.zendesk.com/api/v2/business_hours/schedules.json\-v -u{email_address}:{password}
Go
              
import("fmt""io""net/http")funcmain(){url:="https://support.zendesk.com/api/v2/business_hours/schedules"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/business_hours/schedules").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/business_hours/schedules',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
              
importrequestsurl="https://support.zendesk.com/api/v2/business_hours/schedules"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/business_hours/schedules")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{"schedules":[{"created_at":"2015-09-30T21:44:03Z","id":1,"intervals":[{"end_time":2460,"start_time":1980},{"end_time":3900,"start_time":3420}],"name":"North America","time_zone":"Pacific Time (US & Canada)","updated_at":"2015-09-30T21:44:03Z"},{"created_at":"2015-09-30T21:44:03Z","id":2,"intervals":[{"end_time":2460,"start_time":1980},{"end_time":3900,"start_time":3420}],"name":"EMEA","time_zone":"London","updated_at":"2015-09-30T21:44:03Z"}]}

Show Schedule

  • GET /api/v2/business_hours/schedules/{schedule_id}

Allowed For

  • Agents

Parameters

Name Type In Required Description
schedule_id integer Path true The ID of the schedule

代码示例

curl
              
curlhttps://{subdomain}.zendesk.com/api/v2/business_hours/schedules/{schedule_id}.json\-v -u{email_address}:{password}
Go
              
import("fmt""io""net/http")funcmain(){url:="https://support.zendesk.com/api/v2/business_hours/schedules/1"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/business_hours/schedules/1").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/business_hours/schedules/1',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
              
importrequestsurl="https://support.zendesk.com/api/v2/business_hours/schedules/1"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/business_hours/schedules/1")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{"schedule":{"created_at":"2015-09-30T21:44:03Z","id":1,"intervals":[{"end_time":2460,"start_time":1980},{"end_time":3900,"start_time":3420}],"name":"North America","time_zone":"Pacific Time (US & Canada)","updated_at":"2015-09-30T21:44:03Z"}}

Create Schedule

  • POST /api/v2/business_hours/schedules

Allowed For

  • Admins

代码示例

curl
              
curlhttps://{subdomain}.zendesk.com/api/v2/business_hours/schedules.json\-v -u{email_address}:{password}\-H"Content-Type: application/json"-X POST-d'{"schedule": {"name": "East Coast", "time_zone": "Eastern Time (US & Canada)"}}'
Go
              
import("fmt""io""net/http")funcmain(){url:="https://support.zendesk.com/api/v2/business_hours/schedules"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://support.zendesk.com/api/v2/business_hours/schedules").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://support.zendesk.com/api/v2/business_hours/schedules',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
              
importrequestsurl="https://support.zendesk.com/api/v2/business_hours/schedules"headers={"Content-Type":"application/json",}response=requests.request("POST",url,auth=('',''),headers=headers)print(response.text)
Ruby
              
require"net/http"uri=URI("https://support.zendesk.com/api/v2/business_hours/schedules")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)

201 Created
              
// Status 201 Created{"schedule":{"id":1,"intervals":[{"end_time":2460,"start_time":1980},{"end_time":3900,"start_time":3420},{"end_time":5340,"start_time":4860},{"end_time":6780,"start_time":6300},{"end_time":8220,"start_time":7740}],"name":"East Coast","time_zone":"Eastern Time (US & Canada)"}}

Update Schedule

  • PUT /api/v2/business_hours/schedules/{schedule_id}

Allowed For

  • Admins

Parameters

Name Type In Required Description
schedule_id integer Path true The ID of the schedule

代码示例

curl
              
curlhttps://{subdomain}.zendesk.com/api/v2/business_hours/schedules/{schedule_id}.json\-v -u{email_address}:{password}\-H"Content-Type: application/json"-X PUT-d'{"schedule": {"name": "EMEA", "time_zone": "London"}}'
Go
              
import("fmt""io""net/http")funcmain(){url:="https://support.zendesk.com/api/v2/business_hours/schedules/1"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://support.zendesk.com/api/v2/business_hours/schedules/1").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://support.zendesk.com/api/v2/business_hours/schedules/1',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
              
importrequestsurl="https://support.zendesk.com/api/v2/business_hours/schedules/1"headers={"Content-Type":"application/json",}response=requests.request("PUT",url,auth=('',''),headers=headers)print(response.text)
Ruby
              
require"net/http"uri=URI("https://support.zendesk.com/api/v2/business_hours/schedules/1")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{"schedule":{"created_at":"2015-09-30T21:44:03Z","id":1,"intervals":[{"end_time":2460,"start_time":1980},{"end_time":3900,"start_time":3420},{"end_time":5340,"start_time":4860},{"end_time":6780,"start_time":6300},{"end_time":8220,"start_time":7740}],"name":"EMEA","time_zone":"London","updated_at":"2015-09-30T21:44:03Z"}}

删除Schedule

  • DELETE /api/v2/business_hours/schedules/{schedule_id}

Allowed For

  • Admins

Parameters

Name Type In Required Description
schedule_id integer Path true The ID of the schedule

代码示例

curl
              
curlhttps://{subdomain}.zendesk.com/api/v2/business_hours/schedules/{schedule_id}.json\-v -u{email_address}:{password}\-H"Content-Type: application/json"-X DELETE
Go
              
import("fmt""io""net/http")funcmain(){url:="https://support.zendesk.com/api/v2/business_hours/schedules/1"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://support.zendesk.com/api/v2/business_hours/schedules/1").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://support.zendesk.com/api/v2/business_hours/schedules/1',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
              
importrequestsurl="https://support.zendesk.com/api/v2/business_hours/schedules/1"headers={"Content-Type":"application/json",}response=requests.request("DELETE",url,auth=('',''),headers=headers)print(response.text)
Ruby
              
require"net/http"uri=URI("https://support.zendesk.com/api/v2/business_hours/schedules/1")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)

204 No Content
              
// Status 204 No Contentnull

List Holidays for Schedule

  • GET /api/v2/business_hours/schedules/{schedule_id}/holidays

The endpoint takesstart_dateandend_datequery parameters. If you specify only astart_date, holidays beginning on or after that date are returned. If thestart_datefalls during a holiday, the holiday is also included. As a result the response may list some holidays that start before thestart_date.

If you specify only anend_date, holidays beginning on or before that date are returned.

If you specify both astart_dateand anend_date, holidays beginning between those dates are returned. If you specify neither, all holidays are returned.

Allowed For

  • Admins

Parameters

Name Type In Required Description
end_date string 查询 false Must be in ISO 8601 date format. For example: "2021-01-01".
start_date string 查询 false Must be in ISO 8601 date format. For example, "2021-01-01".
schedule_id integer Path true The ID of the schedule

代码示例

curl
              
curlhttps://{subdomain}.zendesk.com/api/v2/business_hours/schedules/{schedule_id}/holidays.json-v -u{email_address}:{password}
Go
              
import("fmt""io""net/http")funcmain(){url:="https://support.zendesk.com/api/v2/business_hours/schedules/1/holidays?end_date=2021-01-01&start_date=2021-01-01"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/business_hours/schedules/1/holidays").newBuilder().addQueryParameter("end_date","2021-01-01").addQueryParameter("start_date","2021-01-01");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/business_hours/schedules/1/holidays',headers:{'Content-Type':'application/json','Authorization':'Basic ',// Base64 encoded "username:password"},params:{'end_date':'2021-01-01','start_date':'2021-01-01',},};axios(config).then(function(response){console.log(JSON.stringify(response.data));}).catch(function(error){console.log(error);});
Python
              
importrequestsurl="https://support.zendesk.com/api/v2/business_hours/schedules/1/holidays?end_date=2021-01-01&start_date=2021-01-01"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/business_hours/schedules/1/holidays")uri.query=URI.encode_www_form("end_date":"2021-01-01","start_date":"2021-01-01")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{"holidays":[{"end_date":"2021-07-04","id":1,"name":"Independence Day","start_date":"2021-07-04"},{"end_date":"2021-12-25","id":2,"name":"Christmas","start_date":"2021-12-25"}]}

Show Holiday

  • GET /api/v2/business_hours/schedules/{schedule_id}/holidays/{holiday_id}

Allowed For

  • Agents

Parameters

Name Type In Required Description
holiday_id integer Path false The ID of the scheduled holiday
schedule_id integer Path true The ID of the schedule

代码示例

curl
              
curlhttps://{subdomain}.zendesk.com/api/v2/business_hours/schedules/{schedule_id}/holidays/{holiday_id}.json\-v -u{email_address}:{password}
Go
              
import("fmt""io""net/http")funcmain(){url:="https://support.zendesk.com/api/v2/business_hours/schedules/1/holidays/1"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/business_hours/schedules/1/holidays/1").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/business_hours/schedules/1/holidays/1',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
              
importrequestsurl="https://support.zendesk.com/api/v2/business_hours/schedules/1/holidays/1"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/business_hours/schedules/1/holidays/1")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{"holiday":{"end_date":"2021-01-02","id":1,"name":"New Year","start_date":"2020-12-30"}}

Create Holiday

  • POST /api/v2/business_hours/schedules/{schedule_id}/holidays

Creates a holiday defined by a start date no sooner than two years in the past and an end date no later than two years in the future.

Allowed For

  • Admins

Parameters

Name Type In Required Description
schedule_id integer Path true The ID of the schedule

代码示例

curl
              
curlhttps://{subdomain}.zendesk.com/api/v2/business_hours/schedules/{schedule_id}/holidays.json\-d'{"holiday": {"name": "New Year", "start_date": "2021-12-30", "end_date": "2022-01-02"}}'\-H"Content-Type: application/json"-X POST\-v -u{email_address}:{password}
Go
              
import("fmt""io""net/http")funcmain(){url:="https://support.zendesk.com/api/v2/business_hours/schedules/1/holidays"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://support.zendesk.com/api/v2/business_hours/schedules/1/holidays").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://support.zendesk.com/api/v2/business_hours/schedules/1/holidays',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
              
importrequestsurl="https://support.zendesk.com/api/v2/business_hours/schedules/1/holidays"headers={"Content-Type":"application/json",}response=requests.request("POST",url,auth=('',''),headers=headers)print(response.text)
Ruby
              
require"net/http"uri=URI("https://support.zendesk.com/api/v2/business_hours/schedules/1/holidays")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)

201 Created
              
// Status 201 Created{"holiday":{"end_date":"2021-01-02","id":2,"name":"New Year","start_date":"2020-12-30"}}

Update Holiday

  • PUT /api/v2/business_hours/schedules/{schedule_id}/holidays/{holiday_id}

Allowed For

  • Admins

Parameters

Name Type In Required Description
holiday_id integer Path false The ID of the scheduled holiday
schedule_id integer Path true The ID of the schedule

代码示例

curl
              
curlhttps://{subdomain}.zendesk.com/api/v2/business_hours/schedules/{schedule_id}/holidays/{holiday_id}.json\-d'{"holiday": {"name": "New Year", "start_date": "2021-12-30", "end_date": "2022-01-03"}}'\-H"Content-Type: application/json"-X PUT\-v -u{email_address}:{password}
Go
              
import("fmt""io""net/http")funcmain(){url:="https://support.zendesk.com/api/v2/business_hours/schedules/1/holidays/1"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://support.zendesk.com/api/v2/business_hours/schedules/1/holidays/1").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://support.zendesk.com/api/v2/business_hours/schedules/1/holidays/1',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
              
importrequestsurl="https://support.zendesk.com/api/v2/business_hours/schedules/1/holidays/1"headers={"Content-Type":"application/json",}response=requests.request("PUT",url,auth=('',''),headers=headers)print(response.text)
Ruby
              
require"net/http"uri=URI("https://support.zendesk.com/api/v2/business_hours/schedules/1/holidays/1")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{"holiday":{"end_date":"2022-01-03","id":2,"name":"New Year","start_date":"2021-12-30"}}

删除Holiday

  • DELETE /api/v2/business_hours/schedules/{schedule_id}/holidays/{holiday_id}

Allowed For

  • Admins

Parameters

Name Type In Required Description
holiday_id integer Path false The ID of the scheduled holiday
schedule_id integer Path true The ID of the schedule

代码示例

curl
              
curlhttps://{subdomain}.zendesk.com/api/v2/business_hours/schedules/{schedule_id}/holidays/{holiday_id}.json\-H"Content-Type: application/json"-X DELETE\-v -u{email_address}:{password}
Go
              
import("fmt""io""net/http")funcmain(){url:="https://support.zendesk.com/api/v2/business_hours/schedules/1/holidays/1"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://support.zendesk.com/api/v2/business_hours/schedules/1/holidays/1").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://support.zendesk.com/api/v2/business_hours/schedules/1/holidays/1',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
              
importrequestsurl="https://support.zendesk.com/api/v2/business_hours/schedules/1/holidays/1"headers={"Content-Type":"application/json",}response=requests.request("DELETE",url,auth=('',''),headers=headers)print(response.text)
Ruby
              
require"net/http"uri=URI("https://support.zendesk.com/api/v2/business_hours/schedules/1/holidays/1")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)

204 No Content
              
// Status 204 No Contentnull

Update Intervals for a Schedule

  • PUT /api/v2/business_hours/schedules/{schedule_id}/workweek

Allowed For

  • Admins

Parameters

Name Type In Required Description
schedule_id integer Path true The ID of the schedule

代码示例

curl
              
curlhttps://{subdomain}.zendesk.com/api/v2/business_hours/schedules/{schedule_id}/workweek.json\-v -u{email_address}:{password}\-H"Content-Type: application/json"-X PUT\-d'{"workweek": {"intervals": [{"start_time": 3420, "end_time": 3900}]}}'
Go
              
import("fmt""io""net/http")funcmain(){url:="https://support.zendesk.com/api/v2/business_hours/schedules/1/workweek"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://support.zendesk.com/api/v2/business_hours/schedules/1/workweek").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://support.zendesk.com/api/v2/business_hours/schedules/1/workweek',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
              
importrequestsurl="https://support.zendesk.com/api/v2/business_hours/schedules/1/workweek"headers={"Content-Type":"application/json",}response=requests.request("PUT",url,auth=('',''),headers=headers)print(response.text)
Ruby
              
require"net/http"uri=URI("https://support.zendesk.com/api/v2/business_hours/schedules/1/workweek")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{"workweek":{"intervals":[{"end_time":3900,"start_time":3420}]}}