import requests
url = "https://app.langwatch.ai/api/api-keys"
payload = { "name": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>'})
};
fetch('https://app.langwatch.ai/api/api-keys', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://app.langwatch.ai/api/api-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>"
}
'{
"token": "<string>",
"apiKey": {
"id": "<string>",
"name": "<string>",
"createdAt": "2023-11-07T05:31:56Z"
}
}Create API key
Create a new API key. For service keys, pass keyType:“service”. Optionally scope to specific projects via projectIds (ADMIN on each). Omit projectIds for full org access. Pass assignedToUserId to mint the key for another member, and permissionMode:“restricted” with a permissions list to grant exactly those permissions. Minting a service key or a key for another member requires organization admin rights. The plaintext token is returned once — store it securely.
import requests
url = "https://app.langwatch.ai/api/api-keys"
payload = { "name": "<string>" }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>'})
};
fetch('https://app.langwatch.ai/api/api-keys', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://app.langwatch.ai/api/api-keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>"
}
'{
"token": "<string>",
"apiKey": {
"id": "<string>",
"name": "<string>",
"createdAt": "2023-11-07T05:31:56Z"
}
}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}.
Body
Human-readable name for this key
1 - 100A personal key acts as the user who created it and needs explicit bindings. A service key is not tied to a user.
personal, service 500ISO 8601 timestamp after which the key stops working
Organization admins only: the member who owns the key and whose access caps it. Defaults to the caller.
1'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.
What this key may do, and where. Required for a personal key.
20Show child attributes
Show child attributes
Service keys only: restricts the key to these projects
501Was this page helpful?