Rotate a key
curl --request POST \
--url https://control.api.niadra.com/v1/sources/{source_id}/keys/{key_id}/rotate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"grace_seconds": 3600
}
'import requests
url = "https://control.api.niadra.com/v1/sources/{source_id}/keys/{key_id}/rotate"
payload = { "grace_seconds": 3600 }
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_seconds: 3600})
};
fetch('https://control.api.niadra.com/v1/sources/{source_id}/keys/{key_id}/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://control.api.niadra.com/v1/sources/{source_id}/keys/{key_id}/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_seconds' => 3600
]),
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://control.api.niadra.com/v1/sources/{source_id}/keys/{key_id}/rotate"
payload := strings.NewReader("{\n \"grace_seconds\": 3600\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://control.api.niadra.com/v1/sources/{source_id}/keys/{key_id}/rotate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"grace_seconds\": 3600\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://control.api.niadra.com/v1/sources/{source_id}/keys/{key_id}/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_seconds\": 3600\n}"
response = http.request(request)
puts response.read_body{
"key": {
"key_id": "p3Lw8Zr1",
"source_id": "0192f0a0-5f60-7172-8d83-9e0f1a2b3c45",
"scopes": [
"context",
"search",
"track",
"act"
],
"status": "active",
"created_at": "2026-09-24T09:00:00Z",
"expires_at": null,
"revoked_at": null
},
"secret": "nia_sk_live_us-east-1_acme-prod_p3Lw8Zr1_Tq7mB2xK9vN4cR8sL1dH6jW3"
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}Control: sources and keys
Rotate a key
A new key in place of the current one, with the same scopes.
POST
/
v1
/
sources
/
{source_id}
/
keys
/
{key_id}
/
rotate
Rotate a key
curl --request POST \
--url https://control.api.niadra.com/v1/sources/{source_id}/keys/{key_id}/rotate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"grace_seconds": 3600
}
'import requests
url = "https://control.api.niadra.com/v1/sources/{source_id}/keys/{key_id}/rotate"
payload = { "grace_seconds": 3600 }
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_seconds: 3600})
};
fetch('https://control.api.niadra.com/v1/sources/{source_id}/keys/{key_id}/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://control.api.niadra.com/v1/sources/{source_id}/keys/{key_id}/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_seconds' => 3600
]),
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://control.api.niadra.com/v1/sources/{source_id}/keys/{key_id}/rotate"
payload := strings.NewReader("{\n \"grace_seconds\": 3600\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://control.api.niadra.com/v1/sources/{source_id}/keys/{key_id}/rotate")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"grace_seconds\": 3600\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://control.api.niadra.com/v1/sources/{source_id}/keys/{key_id}/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_seconds\": 3600\n}"
response = http.request(request)
puts response.read_body{
"key": {
"key_id": "p3Lw8Zr1",
"source_id": "0192f0a0-5f60-7172-8d83-9e0f1a2b3c45",
"scopes": [
"context",
"search",
"track",
"act"
],
"status": "active",
"created_at": "2026-09-24T09:00:00Z",
"expires_at": null,
"revoked_at": null
},
"secret": "nia_sk_live_us-east-1_acme-prod_p3Lw8Zr1_Tq7mB2xK9vN4cR8sL1dH6jW3"
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
How long the old key keeps working. Defaults to 24 hours; 0 revokes it at once.
Required range:
0 <= x <= 604800
