Rotate
Rotate a secret’s value, replacing the current value with a new one. The previous value is retired and can no longer be read.
curl --request POST \
--url https://api.incident.io/v2/secrets/{id}/actions/rotate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"value": "sk_live_def456"
}
'import requests
url = "https://api.incident.io/v2/secrets/{id}/actions/rotate"
payload = { "value": "sk_live_def456" }
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({value: 'sk_live_def456'})
};
fetch('https://api.incident.io/v2/secrets/{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/v2/secrets/{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([
'value' => 'sk_live_def456'
]),
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/secrets/{id}/actions/rotate"
payload := strings.NewReader("{\n \"value\": \"sk_live_def456\"\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/secrets/{id}/actions/rotate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"value\": \"sk_live_def456\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.incident.io/v2/secrets/{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 \"value\": \"sk_live_def456\"\n}"
response = http.request(request)
puts response.read_body{
"secret": {
"created_at": "2021-08-17T13:28:57.801578Z",
"description": "Auth token for the PagerDuty outgoing webhook",
"id": "01FCNDV6P870EA6S7TK1DSYDG0",
"last_four_chars": "c123",
"name": "PagerDuty webhook token",
"owning_team_ids": [
"01G0J1EXE7AXZ2C93K61WBPYEH"
],
"updated_at": "2021-08-17T13:28:57.801578Z",
"version": 3
}
}Authorizations
API key from your incident.io dashboard (Settings → API keys)
Path Parameters
The secret's ID
"01FCNDV6P870EA6S7TK1DSYDG0"
Body
The secret's new plaintext value. It's stored encrypted and never returned by the API.
"sk_live_def456"
Response
OK response.
A secret is a named credential that workflows can reference, for example an auth token for an outgoing webhook.
Its value can be set and rotated but never read back: the API stores it encrypted and only ever returns masked metadata (the last four characters of the current value). Update the value with the rotate action, which appends a new version and retires the previous one.
Show child attributes
Show child attributes
Was this page helpful?
curl --request POST \
--url https://api.incident.io/v2/secrets/{id}/actions/rotate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"value": "sk_live_def456"
}
'import requests
url = "https://api.incident.io/v2/secrets/{id}/actions/rotate"
payload = { "value": "sk_live_def456" }
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({value: 'sk_live_def456'})
};
fetch('https://api.incident.io/v2/secrets/{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/v2/secrets/{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([
'value' => 'sk_live_def456'
]),
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/secrets/{id}/actions/rotate"
payload := strings.NewReader("{\n \"value\": \"sk_live_def456\"\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/secrets/{id}/actions/rotate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"value\": \"sk_live_def456\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.incident.io/v2/secrets/{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 \"value\": \"sk_live_def456\"\n}"
response = http.request(request)
puts response.read_body{
"secret": {
"created_at": "2021-08-17T13:28:57.801578Z",
"description": "Auth token for the PagerDuty outgoing webhook",
"id": "01FCNDV6P870EA6S7TK1DSYDG0",
"last_four_chars": "c123",
"name": "PagerDuty webhook token",
"owning_team_ids": [
"01G0J1EXE7AXZ2C93K61WBPYEH"
],
"updated_at": "2021-08-17T13:28:57.801578Z",
"version": 3
}
}