Rotate
Rotate the access token for an API key. This generates a new bearer token and optionally keeps the old token valid for a configurable grace period (up to 60 minutes), allowing a seamless rollover without downtime. The calling API key must have all the scopes of the key being rotated.
This endpoint requires a valid API key with the api_keys_manage role at either the account level or team level.
POST
/
v1
/
api_keys
/
{id}
/
actions
/
rotate
Rotate
curl --request POST \
--url https://api.incident.io/v1/api_keys/{id}/actions/rotate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"grace_period_minutes": 30
}
'import requests
url = "https://api.incident.io/v1/api_keys/{id}/actions/rotate"
payload = { "grace_period_minutes": 30 }
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({grace_period_minutes: 30})
};
fetch('https://api.incident.io/v1/api_keys/{id}/actions/rotate', 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/v1/api_keys/{id}/actions/rotate",
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([
'grace_period_minutes' => 30
]),
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/v1/api_keys/{id}/actions/rotate"
payload := strings.NewReader("{\n \"grace_period_minutes\": 30\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/v1/api_keys/{id}/actions/rotate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"grace_period_minutes\": 30\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.incident.io/v1/api_keys/{id}/actions/rotate")
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 \"grace_period_minutes\": 30\n}"
response = http.request(request)
puts response.read_body{
"api_key": {
"comments": "Requested in https://example.slack.com/archives/C123/p456",
"created_at": "2021-08-17T13:28:57.801578Z",
"creator": {
"api_key": {
"id": "01FCNDV6P870EA6S7TK1DSYDG0",
"name": "My test API key"
},
"user": {
"email": "lisa@incident.io",
"id": "01FCNDV6P870EA6S7TK1DSYDG0",
"name": "Lisa Karlin Curtis",
"role": "viewer",
"slack_user_id": "U02AYNF2XJM"
}
},
"id": "01FCNDV6P870EA6S7TK1DSYDG0",
"last_used_at": "2021-08-17T13:28:57.801578Z",
"name": "My test API key",
"roles": [
{
"description": "can view data, like public incidents and organization settings",
"name": "viewer"
}
],
"team_ids": [
"abc123"
],
"team_roles": [
{
"description": "can view data, like public incidents and organization settings",
"name": "catalog_editor"
}
],
"token_last_issued_at": "2021-08-17T13:28:57.801578Z"
},
"token": "inc_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
}🔑 Requires the
api_keys.rotate scope.Authorizations
API key from your incident.io dashboard (Settings → API keys)
Path Parameters
Unique identifier of the API key to rotate
Example:
"01FCNDV6P870EA6S7TK1DSYDG0"
Body
application/json
How many minutes to keep the old access token alive.
Required range:
0 <= x <= 60Example:
30
Was this page helpful?
⌘I
Rotate
curl --request POST \
--url https://api.incident.io/v1/api_keys/{id}/actions/rotate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"grace_period_minutes": 30
}
'import requests
url = "https://api.incident.io/v1/api_keys/{id}/actions/rotate"
payload = { "grace_period_minutes": 30 }
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({grace_period_minutes: 30})
};
fetch('https://api.incident.io/v1/api_keys/{id}/actions/rotate', 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/v1/api_keys/{id}/actions/rotate",
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([
'grace_period_minutes' => 30
]),
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/v1/api_keys/{id}/actions/rotate"
payload := strings.NewReader("{\n \"grace_period_minutes\": 30\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/v1/api_keys/{id}/actions/rotate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"grace_period_minutes\": 30\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.incident.io/v1/api_keys/{id}/actions/rotate")
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 \"grace_period_minutes\": 30\n}"
response = http.request(request)
puts response.read_body{
"api_key": {
"comments": "Requested in https://example.slack.com/archives/C123/p456",
"created_at": "2021-08-17T13:28:57.801578Z",
"creator": {
"api_key": {
"id": "01FCNDV6P870EA6S7TK1DSYDG0",
"name": "My test API key"
},
"user": {
"email": "lisa@incident.io",
"id": "01FCNDV6P870EA6S7TK1DSYDG0",
"name": "Lisa Karlin Curtis",
"role": "viewer",
"slack_user_id": "U02AYNF2XJM"
}
},
"id": "01FCNDV6P870EA6S7TK1DSYDG0",
"last_used_at": "2021-08-17T13:28:57.801578Z",
"name": "My test API key",
"roles": [
{
"description": "can view data, like public incidents and organization settings",
"name": "viewer"
}
],
"team_ids": [
"abc123"
],
"team_roles": [
{
"description": "can view data, like public incidents and organization settings",
"name": "catalog_editor"
}
],
"token_last_issued_at": "2021-08-17T13:28:57.801578Z"
},
"token": "inc_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
}