Rotate virtual key secret
import requests
url = "https://app.langwatch.ai/api/gateway/v1/virtual-keys/{id}/rotate"
headers = {"X-Auth-Token": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'X-Auth-Token': '<api-key>'}};
fetch('https://app.langwatch.ai/api/gateway/v1/virtual-keys/{id}/rotate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://app.langwatch.ai/api/gateway/v1/virtual-keys/{id}/rotate \
--header 'X-Auth-Token: <api-key>'{
"virtual_key": {
"id": "<string>",
"organization_id": "<string>",
"name": "<string>",
"description": "<string>",
"status": "active",
"purpose": "user",
"display_prefix": "<string>",
"principal_user_id": "<string>",
"trace_project_id": "<string>",
"trace_project_archived": true,
"external_id": "<string>",
"metadata": {},
"scopes": [
{
"scope_type": "organization",
"scope_id": "<string>"
}
],
"routing_policy_id": "<string>",
"routing_mode": "none",
"revision": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"last_used_at": "2023-11-07T05:31:56Z",
"revoked_at": "2023-11-07T05:31:56Z",
"expires_at": "2023-11-07T05:31:56Z",
"config": "<unknown>"
},
"secret": "<string>"
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}Gateway: Virtual Keys
Rotate virtual key secret
Mints a fresh secret for an existing VK. The old secret remains valid for 24h (grace window) so in-flight clients can roll over.
POST
/
api
/
gateway
/
v1
/
virtual-keys
/
{id}
/
rotate
Rotate virtual key secret
import requests
url = "https://app.langwatch.ai/api/gateway/v1/virtual-keys/{id}/rotate"
headers = {"X-Auth-Token": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'X-Auth-Token': '<api-key>'}};
fetch('https://app.langwatch.ai/api/gateway/v1/virtual-keys/{id}/rotate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://app.langwatch.ai/api/gateway/v1/virtual-keys/{id}/rotate \
--header 'X-Auth-Token: <api-key>'{
"virtual_key": {
"id": "<string>",
"organization_id": "<string>",
"name": "<string>",
"description": "<string>",
"status": "active",
"purpose": "user",
"display_prefix": "<string>",
"principal_user_id": "<string>",
"trace_project_id": "<string>",
"trace_project_archived": true,
"external_id": "<string>",
"metadata": {},
"scopes": [
{
"scope_type": "organization",
"scope_id": "<string>"
}
],
"routing_policy_id": "<string>",
"routing_mode": "none",
"revision": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"last_used_at": "2023-11-07T05:31:56Z",
"revoked_at": "2023-11-07T05:31:56Z",
"expires_at": "2023-11-07T05:31:56Z",
"config": "<unknown>"
},
"secret": "<string>"
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}{
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"meta": {},
"trace_id": "<string>",
"span_id": "<string>"
}
}Authorizations
Project API key for sending traces and accessing project-scoped resources. Format: sk-lw-... (no underscore). Obtain one by creating a project via the Admin API or the LangWatch UI.
Path Parameters
Last modified on May 19, 2026
Was this page helpful?
⌘I