Create
Create a new secret with its initial value.
curl --request POST \
--url https://api.incident.io/v2/secrets \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"description": "Auth token for the PagerDuty outgoing webhook",
"name": "PagerDuty webhook token",
"owning_team_ids": [
"01G0J1EXE7AXZ2C93K61WBPYEH"
],
"value": "sk_live_abc123"
}
'import requests
url = "https://api.incident.io/v2/secrets"
payload = {
"description": "Auth token for the PagerDuty outgoing webhook",
"name": "PagerDuty webhook token",
"owning_team_ids": ["01G0J1EXE7AXZ2C93K61WBPYEH"],
"value": "sk_live_abc123"
}
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({
description: 'Auth token for the PagerDuty outgoing webhook',
name: 'PagerDuty webhook token',
owning_team_ids: ['01G0J1EXE7AXZ2C93K61WBPYEH'],
value: 'sk_live_abc123'
})
};
fetch('https://api.incident.io/v2/secrets', 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",
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([
'description' => 'Auth token for the PagerDuty outgoing webhook',
'name' => 'PagerDuty webhook token',
'owning_team_ids' => [
'01G0J1EXE7AXZ2C93K61WBPYEH'
],
'value' => 'sk_live_abc123'
]),
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"
payload := strings.NewReader("{\n \"description\": \"Auth token for the PagerDuty outgoing webhook\",\n \"name\": \"PagerDuty webhook token\",\n \"owning_team_ids\": [\n \"01G0J1EXE7AXZ2C93K61WBPYEH\"\n ],\n \"value\": \"sk_live_abc123\"\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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"description\": \"Auth token for the PagerDuty outgoing webhook\",\n \"name\": \"PagerDuty webhook token\",\n \"owning_team_ids\": [\n \"01G0J1EXE7AXZ2C93K61WBPYEH\"\n ],\n \"value\": \"sk_live_abc123\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.incident.io/v2/secrets")
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 \"description\": \"Auth token for the PagerDuty outgoing webhook\",\n \"name\": \"PagerDuty webhook token\",\n \"owning_team_ids\": [\n \"01G0J1EXE7AXZ2C93K61WBPYEH\"\n ],\n \"value\": \"sk_live_abc123\"\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)
Body
Human-readable name, unique within the organisation amongst unarchived secrets
"PagerDuty webhook token"
The secret's plaintext value. It's stored encrypted and never returned by the API.
"sk_live_abc123"
Optional description of what this secret is for
"Auth token for the PagerDuty outgoing webhook"
IDs of the teams that own this secret. When empty or omitted, the secret is owned by the whole organisation.
["01G0J1EXE7AXZ2C93K61WBPYEH"]
Response
Created 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 \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"description": "Auth token for the PagerDuty outgoing webhook",
"name": "PagerDuty webhook token",
"owning_team_ids": [
"01G0J1EXE7AXZ2C93K61WBPYEH"
],
"value": "sk_live_abc123"
}
'import requests
url = "https://api.incident.io/v2/secrets"
payload = {
"description": "Auth token for the PagerDuty outgoing webhook",
"name": "PagerDuty webhook token",
"owning_team_ids": ["01G0J1EXE7AXZ2C93K61WBPYEH"],
"value": "sk_live_abc123"
}
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({
description: 'Auth token for the PagerDuty outgoing webhook',
name: 'PagerDuty webhook token',
owning_team_ids: ['01G0J1EXE7AXZ2C93K61WBPYEH'],
value: 'sk_live_abc123'
})
};
fetch('https://api.incident.io/v2/secrets', 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",
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([
'description' => 'Auth token for the PagerDuty outgoing webhook',
'name' => 'PagerDuty webhook token',
'owning_team_ids' => [
'01G0J1EXE7AXZ2C93K61WBPYEH'
],
'value' => 'sk_live_abc123'
]),
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"
payload := strings.NewReader("{\n \"description\": \"Auth token for the PagerDuty outgoing webhook\",\n \"name\": \"PagerDuty webhook token\",\n \"owning_team_ids\": [\n \"01G0J1EXE7AXZ2C93K61WBPYEH\"\n ],\n \"value\": \"sk_live_abc123\"\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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"description\": \"Auth token for the PagerDuty outgoing webhook\",\n \"name\": \"PagerDuty webhook token\",\n \"owning_team_ids\": [\n \"01G0J1EXE7AXZ2C93K61WBPYEH\"\n ],\n \"value\": \"sk_live_abc123\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.incident.io/v2/secrets")
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 \"description\": \"Auth token for the PagerDuty outgoing webhook\",\n \"name\": \"PagerDuty webhook token\",\n \"owning_team_ids\": [\n \"01G0J1EXE7AXZ2C93K61WBPYEH\"\n ],\n \"value\": \"sk_live_abc123\"\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
}
}