Create
Create a new sync rule linking a schedule to a sync target.
curl --request POST \
--url https://api.incident.io/v2/schedules/{schedule_id}/sync_rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"schedule_sync_rule": {
"annotations": {
"incident.io/terraform/version": "3.0.0"
},
"rotation_id": "01JXYZ000000000000000000RT",
"schedule_sync_target_id": "01JXYZ000000000000000000AB",
"sync_type": "on_call"
}
}
'import requests
url = "https://api.incident.io/v2/schedules/{schedule_id}/sync_rules"
payload = { "schedule_sync_rule": {
"annotations": { "incident.io/terraform/version": "3.0.0" },
"rotation_id": "01JXYZ000000000000000000RT",
"schedule_sync_target_id": "01JXYZ000000000000000000AB",
"sync_type": "on_call"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
schedule_sync_rule: {
annotations: {'incident.io/terraform/version': '3.0.0'},
rotation_id: '01JXYZ000000000000000000RT',
schedule_sync_target_id: '01JXYZ000000000000000000AB',
sync_type: 'on_call'
}
})
};
fetch('https://api.incident.io/v2/schedules/{schedule_id}/sync_rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.incident.io/v2/schedules/{schedule_id}/sync_rules",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'schedule_sync_rule' => [
'annotations' => [
'incident.io/terraform/version' => '3.0.0'
],
'rotation_id' => '01JXYZ000000000000000000RT',
'schedule_sync_target_id' => '01JXYZ000000000000000000AB',
'sync_type' => 'on_call'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.incident.io/v2/schedules/{schedule_id}/sync_rules"
payload := strings.NewReader("{\n \"schedule_sync_rule\": {\n \"annotations\": {\n \"incident.io/terraform/version\": \"3.0.0\"\n },\n \"rotation_id\": \"01JXYZ000000000000000000RT\",\n \"schedule_sync_target_id\": \"01JXYZ000000000000000000AB\",\n \"sync_type\": \"on_call\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.incident.io/v2/schedules/{schedule_id}/sync_rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"schedule_sync_rule\": {\n \"annotations\": {\n \"incident.io/terraform/version\": \"3.0.0\"\n },\n \"rotation_id\": \"01JXYZ000000000000000000RT\",\n \"schedule_sync_target_id\": \"01JXYZ000000000000000000AB\",\n \"sync_type\": \"on_call\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.incident.io/v2/schedules/{schedule_id}/sync_rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"schedule_sync_rule\": {\n \"annotations\": {\n \"incident.io/terraform/version\": \"3.0.0\"\n },\n \"rotation_id\": \"01JXYZ000000000000000000RT\",\n \"schedule_sync_target_id\": \"01JXYZ000000000000000000AB\",\n \"sync_type\": \"on_call\"\n }\n}"
response = http.request(request)
puts response.read_body{
"schedule_sync_rule": {
"created_at": "2021-08-17T13:28:57.801578Z",
"id": "01JXYZ000000000000000000CD",
"rotation_id": "01JXYZ000000000000000000RT",
"schedule_id": "01JXYZ000000000000000000EF",
"schedule_sync_target": {
"add_bot_to_group": true,
"created_at": "2021-08-17T13:28:57.801578Z",
"id": "01JXYZ000000000000000000AB",
"linked_schedules": [
{
"id": "01G0J1EXE7AXZ2C93K61WBPYEH",
"name": "Primary On-Call Schedule",
"team_ids": [
"01JPQA75EPNEES4479P16P4XAB"
]
}
],
"slack_team_id": "T02A1AZHG3J",
"slack_user_group_id": "S06MNNU5BMK",
"updated_at": "2021-08-17T13:28:57.801578Z"
},
"schedule_sync_target_id": "01JXYZ000000000000000000AB",
"sync_type": "on_call",
"updated_at": "2021-08-17T13:28:57.801578Z"
}
}Authorizations
API key from your incident.io dashboard (Settings → API keys)
Path Parameters
The schedule to create a sync rule for
"01FDAG4SAP5TYPT98WGR2N7W91"
Body
Show child attributes
Show child attributes
{
"annotations": { "incident.io/terraform/version": "3.0.0" },
"rotation_id": "01JXYZ000000000000000000RT",
"schedule_sync_target_id": "01JXYZ000000000000000000AB",
"sync_type": "on_call"
}
Response
Created response.
A sync rule links a schedule to a sync target, telling us which of the schedule's members should flow into the target's Slack user group.
sync_type decides who is synced: on_call syncs only the people currently on call, while all_users syncs everyone on the schedule. By default every rotation on the schedule is included; set rotation_id to scope the rule to a single rotation. As the schedule's shifts change hands, we keep the target's Slack user group membership in step with the rule.
Show child attributes
Show child attributes
Was this page helpful?
curl --request POST \
--url https://api.incident.io/v2/schedules/{schedule_id}/sync_rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"schedule_sync_rule": {
"annotations": {
"incident.io/terraform/version": "3.0.0"
},
"rotation_id": "01JXYZ000000000000000000RT",
"schedule_sync_target_id": "01JXYZ000000000000000000AB",
"sync_type": "on_call"
}
}
'import requests
url = "https://api.incident.io/v2/schedules/{schedule_id}/sync_rules"
payload = { "schedule_sync_rule": {
"annotations": { "incident.io/terraform/version": "3.0.0" },
"rotation_id": "01JXYZ000000000000000000RT",
"schedule_sync_target_id": "01JXYZ000000000000000000AB",
"sync_type": "on_call"
} }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
schedule_sync_rule: {
annotations: {'incident.io/terraform/version': '3.0.0'},
rotation_id: '01JXYZ000000000000000000RT',
schedule_sync_target_id: '01JXYZ000000000000000000AB',
sync_type: 'on_call'
}
})
};
fetch('https://api.incident.io/v2/schedules/{schedule_id}/sync_rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.incident.io/v2/schedules/{schedule_id}/sync_rules",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'schedule_sync_rule' => [
'annotations' => [
'incident.io/terraform/version' => '3.0.0'
],
'rotation_id' => '01JXYZ000000000000000000RT',
'schedule_sync_target_id' => '01JXYZ000000000000000000AB',
'sync_type' => 'on_call'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.incident.io/v2/schedules/{schedule_id}/sync_rules"
payload := strings.NewReader("{\n \"schedule_sync_rule\": {\n \"annotations\": {\n \"incident.io/terraform/version\": \"3.0.0\"\n },\n \"rotation_id\": \"01JXYZ000000000000000000RT\",\n \"schedule_sync_target_id\": \"01JXYZ000000000000000000AB\",\n \"sync_type\": \"on_call\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.incident.io/v2/schedules/{schedule_id}/sync_rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"schedule_sync_rule\": {\n \"annotations\": {\n \"incident.io/terraform/version\": \"3.0.0\"\n },\n \"rotation_id\": \"01JXYZ000000000000000000RT\",\n \"schedule_sync_target_id\": \"01JXYZ000000000000000000AB\",\n \"sync_type\": \"on_call\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.incident.io/v2/schedules/{schedule_id}/sync_rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"schedule_sync_rule\": {\n \"annotations\": {\n \"incident.io/terraform/version\": \"3.0.0\"\n },\n \"rotation_id\": \"01JXYZ000000000000000000RT\",\n \"schedule_sync_target_id\": \"01JXYZ000000000000000000AB\",\n \"sync_type\": \"on_call\"\n }\n}"
response = http.request(request)
puts response.read_body{
"schedule_sync_rule": {
"created_at": "2021-08-17T13:28:57.801578Z",
"id": "01JXYZ000000000000000000CD",
"rotation_id": "01JXYZ000000000000000000RT",
"schedule_id": "01JXYZ000000000000000000EF",
"schedule_sync_target": {
"add_bot_to_group": true,
"created_at": "2021-08-17T13:28:57.801578Z",
"id": "01JXYZ000000000000000000AB",
"linked_schedules": [
{
"id": "01G0J1EXE7AXZ2C93K61WBPYEH",
"name": "Primary On-Call Schedule",
"team_ids": [
"01JPQA75EPNEES4479P16P4XAB"
]
}
],
"slack_team_id": "T02A1AZHG3J",
"slack_user_group_id": "S06MNNU5BMK",
"updated_at": "2021-08-17T13:28:57.801578Z"
},
"schedule_sync_target_id": "01JXYZ000000000000000000AB",
"sync_type": "on_call",
"updated_at": "2021-08-17T13:28:57.801578Z"
}
}