import requests
url = "https://app.langwatch.ai/api/api-keys/{id}"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://app.langwatch.ai/api/api-keys/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request PATCH \
--url https://app.langwatch.ai/api/api-keys/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'{
"id": "<string>",
"name": "<string>",
"description": "<string>",
"assignedToUserId": "<string>",
"createdByUserId": "<string>",
"permissions": [
"<string>"
],
"createdAt": "2023-11-07T05:31:56Z",
"expiresAt": "2023-11-07T05:31:56Z",
"lastUsedAt": "2023-11-07T05:31:56Z",
"revokedAt": "2023-11-07T05:31:56Z",
"roleBindings": [
{
"id": "<string>",
"scopeId": "<string>"
}
],
"bindings": [
{
"scopeId": "<string>"
}
]
}Update an API key
Update an API key’s name, description, permission mode, permissions or bindings. Every field is optional; bindings are replaced outright, and the response is exactly what a subsequent GET returns. You may update your own keys; organization admins may update any key in the organization. Bindings can never exceed the access of the member the key belongs to. The token itself never changes.
import requests
url = "https://app.langwatch.ai/api/api-keys/{id}"
payload = {}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({})
};
fetch('https://app.langwatch.ai/api/api-keys/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request PATCH \
--url https://app.langwatch.ai/api/api-keys/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{}'{
"id": "<string>",
"name": "<string>",
"description": "<string>",
"assignedToUserId": "<string>",
"createdByUserId": "<string>",
"permissions": [
"<string>"
],
"createdAt": "2023-11-07T05:31:56Z",
"expiresAt": "2023-11-07T05:31:56Z",
"lastUsedAt": "2023-11-07T05:31:56Z",
"revokedAt": "2023-11-07T05:31:56Z",
"roleBindings": [
{
"id": "<string>",
"scopeId": "<string>"
}
],
"bindings": [
{
"scopeId": "<string>"
}
]
}Authorizations
Admin API key for organization-level operations (managing projects, API keys). Create one in Settings > API Keys or via POST /api/api-keys. Format: sk-lw-{id}_{secret}.
Path Parameters
API key ID
Body
1 - 100500'all' and 'readonly' take their meaning from the bindings alone; 'restricted' additionally requires an explicit permissions list.
all, readonly, restricted Restricted mode only: the exact resource:action permissions the key's CUSTOM bindings grant.
Replaces the key's bindings outright. Whatever is accepted here is exactly what a subsequent GET returns.
1 - 20 elementsShow child attributes
Show child attributes
Response
The updated API key
personal, service The member who owns the key; null for a service key.
all, readonly, restricted The resource:action permissions a restricted key grants. Empty for the other modes.
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?