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}.
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, held by both the key making the request and its member. A key can grant at most what the key making the request holds. The plaintext token is returned once — store it securely.
Try this endpoint
app.langwatch.ai
API key · Authorization
Kept in this tab. Cleared when you reload.
Human-readable name for this key
A personal key acts as the user who created it and needs explicit bindings. A service key is not tied to a user.
In UTC. ISO 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.
'all' and 'readonly' take their meaning from the bindings alone; 'restricted' additionally requires an explicit permissions list.
What this key may do, and where. Required for a personal key.
This sends a live request to app.langwatch.ai.
Request and response examples
import osimport requestsorigin = "https://app.langwatch.ai"path = "/api/v1/api-keys"api_key = os.environ["LANGWATCH_API_KEY"]headers = { "Authorization": "Bearer " + api_key, "Content-Type": "application/json",}payload = {}response = requests.post( origin + path, headers=headers, json=payload,)print(response.json())const url = "https://app.langwatch.ai/api/v1/api-keys";const response = await fetch(url, { method: "POST", headers: { "Authorization": "Bearer " + process.env.LANGWATCH_API_KEY, "Content-Type": "application/json", }, body: JSON.stringify({}),});const data = await response.json();curl --request POST \ --url 'https://app.langwatch.ai/api/v1/api-keys' \ --header "Authorization: Bearer $LANGWATCH_API_KEY" \ --header 'Content-Type: application/json' \ --data '{}'Call the LangWatch API from this project: Create an API key.Request: POST https://app.langwatch.ai/api/v1/api-keysReference: https://langwatch.ai/docs/api-reference/api-keys/create-api-key.mdAuthentication: send the Authorization header as a Bearer token, read from the LANGWATCH_API_KEY environment variable. Never hard-code the key.Body (application/json):```json{}```Use the HTTP client this project already uses, handle non-2xx responses, and show me the parsed result.Success
application/json · Generated from schema
{ "token": "string", "apiKey": { "id": "string", "name": "string", "createdAt": "2026-01-01T00:00:00Z" }}Invalid or missing API key token
Requested binding exceeds what the key making the request holds, or the scope does not belong to this organization (api_key_scope_violation); a service key or a key for another member was requested without organization admin rights (api_key_admin_required)
Validation error, for example a missing name or empty bindings (validation_error), or a name LangWatch reserves for its own keys (api_key_reserved_name)
Request body
application/json · Required
keyTypestringA personal key acts as the user who created it and needs explicit bindings. A service key is not tied to a user.
"personal""service""personal"namestringrequiredHuman-readable name for this key
descriptionstringexpiresAtstring (date-time)ISO 8601 timestamp after which the key stops working
assignedToUserIdstringOrganization admins only: the member who owns the key and whose access caps it. Defaults to the caller.
permissionModestring'all' and 'readonly' take their meaning from the bindings alone; 'restricted' additionally requires an explicit permissions list.
"all""readonly""restricted""all"permissionsstring[]Restricted mode only: the exact resource:action permissions the key's CUSTOM bindings grant.
bindingsobject[]What this key may do, and where. Required for a personal key.
projectIdsstring[]Service keys only: restricts the key to these projects
Responses
201Success
application/json
tokenstringrequiredapiKeyobjectrequired