curl --request POST \
--url https://{host}/v2/workspaces/slug:storage/webhooks/v1/knowledge_bases/{knowledgeBaseId}/api-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expires_at": 123
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({expires_at: 123})
};
fetch('https://{host}/v2/workspaces/slug:storage/webhooks/v1/knowledge_bases/{knowledgeBaseId}/api-keys', 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"
payload = { "expires_at": 123 }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, 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
}Mint an API key
Creates an API key (minted scope storage:vector_stores:{id} -
the knowledge_bases rename is deferred with the platform
allowlist). The secret is returned ONCE in this response and
never again. expires_at is required - the platform key
service rejects a key with no expiry. Requires admin+ (or owner).
curl --request POST \
--url https://{host}/v2/workspaces/slug:storage/webhooks/v1/knowledge_bases/{knowledgeBaseId}/api-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expires_at": 123
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({expires_at: 123})
};
fetch('https://{host}/v2/workspaces/slug:storage/webhooks/v1/knowledge_bases/{knowledgeBaseId}/api-keys', 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"
payload = { "expires_at": 123 }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, 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-]+$Body
Response
Key created; 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?