curl --request POST \
--url https://{host}/v2/workspaces/slug:storage/webhooks/v1/knowledge_bases/{knowledgeBaseId}/api-keys/{apiKeyId}/rotate \
--header 'Authorization: Bearer <token>'const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://{host}/v2/workspaces/slug:storage/webhooks/v1/knowledge_bases/{knowledgeBaseId}/api-keys/{apiKeyId}/rotate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://{host}/v2/workspaces/slug:storage/webhooks/v1/knowledge_bases/{knowledgeBaseId}/api-keys/{apiKeyId}/rotate"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text){
"id": "<string>",
"object": "knowledge_base.api_key",
"knowledge_base_id": "<string>",
"scope": "<string>",
"created_at": 123,
"name": "<string>",
"slug": "<string>",
"permissions": [
"<string>"
],
"prefix": "<string>",
"last_used_at": 123,
"expires_at": 123,
"created_by": "<string>",
"updated_at": 123
}Rotate an API key
Issues a new secret for the same key id and invalidates the
previous secret. The new secret is returned ONCE. Requires
admin+ (or owner).
curl --request POST \
--url https://{host}/v2/workspaces/slug:storage/webhooks/v1/knowledge_bases/{knowledgeBaseId}/api-keys/{apiKeyId}/rotate \
--header 'Authorization: Bearer <token>'const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://{host}/v2/workspaces/slug:storage/webhooks/v1/knowledge_bases/{knowledgeBaseId}/api-keys/{apiKeyId}/rotate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://{host}/v2/workspaces/slug:storage/webhooks/v1/knowledge_bases/{knowledgeBaseId}/api-keys/{apiKeyId}/rotate"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text){
"id": "<string>",
"object": "knowledge_base.api_key",
"knowledge_base_id": "<string>",
"scope": "<string>",
"created_at": 123,
"name": "<string>",
"slug": "<string>",
"permissions": [
"<string>"
],
"prefix": "<string>",
"last_used_at": 123,
"expires_at": 123,
"created_by": "<string>",
"updated_at": 123
}Authorizations
User session JWT or instance API key (iak_*). Send as Authorization: Bearer <token>.
Path Parameters
Knowledge base id. Legacy physical prefix vs_ (the kb_ rename is deferred).
128^vs_[A-Za-z0-9-]+$Knowledge-base API key identifier - the key slug
(auto-generated as kb-{knowledge_base_id}-{uuid}, or
caller-supplied). This is the value returned as ApiKey.id.
128^kb-[A-Za-z0-9_-]+$Response
Rotated; new secret present (once).
Per-knowledge-base API key metadata (no secret).
The key slug (also exposed as slug).
^kb-[A-Za-z0-9_-]+$knowledge_base.api_key ^vs_[A-Za-z0-9-]+$Currently storage:vector_stores:{knowledge_base_id} (the
storage:knowledge_bases:{id} rename is deferred with the
platform allowlist change).
256Path-safe key identifier (kb-{knowledge_base_id}-{uuid}, or
caller-supplied at mint). Equal to id.
The storage:-prefixed permission strings the key grants
(caller-provided at mint, else config.api_key_default_permissions).
Non-secret leading characters, for identification in lists.
Was this page helpful?