Rotate an API key
curl --request POST \
--url https://{host}/v2/workspaces/slug:ai-collection-v3/webhooks/v1/collections/{collection_id}/api-keys/{key_id}/rotate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expiresAt": "2023-11-07T05:31:56Z"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({expiresAt: '2023-11-07T05:31:56Z'})
};
fetch('https://{host}/v2/workspaces/slug:ai-collection-v3/webhooks/v1/collections/{collection_id}/api-keys/{key_id}/rotate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://{host}/v2/workspaces/slug:ai-collection-v3/webhooks/v1/collections/{collection_id}/api-keys/{key_id}/rotate"
payload = { "expiresAt": "2023-11-07T05:31:56Z" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "<string>",
"object": "collection.api_key",
"collection_id": "<string>",
"slug": "<string>",
"name": "<string>",
"scope": "ai-collection-v3:collections:3f2a9c1e-...",
"permissions": [
"<string>"
],
"expires_at": 123,
"secret": "<string>"
}{
"error": "InvalidArguments",
"message": "<string>"
}{
"error": "InvalidArguments",
"message": "<string>"
}{
"error": "InvalidArguments",
"message": "<string>"
}API Keys
Rotate an API key
Regenerates the key. The new raw key is returned once, in secret. Requires ai-collection-v3:collections:share and the ai-collection-v3:apikeys:create org permission (403 otherwise).
POST
/
v1
/
collections
/
{collection_id}
/
api-keys
/
{key_id}
/
rotate
Rotate an API key
curl --request POST \
--url https://{host}/v2/workspaces/slug:ai-collection-v3/webhooks/v1/collections/{collection_id}/api-keys/{key_id}/rotate \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expiresAt": "2023-11-07T05:31:56Z"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({expiresAt: '2023-11-07T05:31:56Z'})
};
fetch('https://{host}/v2/workspaces/slug:ai-collection-v3/webhooks/v1/collections/{collection_id}/api-keys/{key_id}/rotate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://{host}/v2/workspaces/slug:ai-collection-v3/webhooks/v1/collections/{collection_id}/api-keys/{key_id}/rotate"
payload = { "expiresAt": "2023-11-07T05:31:56Z" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "<string>",
"object": "collection.api_key",
"collection_id": "<string>",
"slug": "<string>",
"name": "<string>",
"scope": "ai-collection-v3:collections:3f2a9c1e-...",
"permissions": [
"<string>"
],
"expires_at": 123,
"secret": "<string>"
}{
"error": "InvalidArguments",
"message": "<string>"
}{
"error": "InvalidArguments",
"message": "<string>"
}{
"error": "InvalidArguments",
"message": "<string>"
}Authorizations
BearerAuthOrgApiKeyAuth
User session JWT. Send as Authorization: Bearer <token>.
Path Parameters
Collection identifier returned at creation.
Body
application/json
New expiration date, in the future. Without it, the key keeps its expiration. Required to rotate a key that has already expired (400 otherwise).
Response
Key rotated. secret is shown only once.
API key metadata. The raw key is never included here.
Was this page helpful?