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}.
Change a grant's role
Change the role a grant confers. The principal and scope are the grant's identity and do not change. Lowering the organization's last administrator answers cannot_demote_last_admin. A grant never confers a permission the caller does not hold at that scope: 403 grant_exceeds_caller_permissions names the missing permissions.
Try this endpoint
app.langwatch.ai
API key · Authorization
Kept in this tab. Cleared when you reload.
Body (application/json)
This sends a live request to app.langwatch.ai.
Request and response examples
request.py
import osimport requestsorigin = "https://app.langwatch.ai"path = "/api/v1/grants/<grantId>"api_key = os.environ["LANGWATCH_API_KEY"]headers = { "Authorization": "Bearer " + api_key, "Content-Type": "application/json",}payload = {}response = requests.patch( origin + path, headers=headers, json=payload,)print(response.json())const url = "https://app.langwatch.ai/api/v1/grants/<grantId>";const response = await fetch(url, { method: "PATCH", headers: { "Authorization": "Bearer " + process.env.LANGWATCH_API_KEY, "Content-Type": "application/json", }, body: JSON.stringify({}),});const data = await response.json();curl --request PATCH \ --url 'https://app.langwatch.ai/api/v1/grants/<grantId>' \ --header "Authorization: Bearer $LANGWATCH_API_KEY" \ --header 'Content-Type: application/json' \ --data '{}'Call the LangWatch API from this project: Change a grant's role.Request: PATCH https://app.langwatch.ai/api/v1/grants/<grantId>Reference: https://langwatch.ai/docs/api-reference/grants/change-a-grant-s-role.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
{ "id": "string", "principal": { "type": "user", "id": "string", "name": "string" }, "role": { "id": "string", "name": "string", "builtIn": false }, "scope": { "type": "organization", "id": "string", "name": "string" }, "status": "active", "expiresAt": "2026-01-01T00:00:00Z", "createdAt": "2026-01-01T00:00:00Z"}Path parameters
grantIdstringrequiredAt least 1 characterUp to 128 characters
Request body
application/json · Required
roleIdstringrequiredAt least 1 characterUp to 128 characters
Responses
200Success
application/json
idstringrequiredprincipalobjectrequiredroleobjectrequiredscopeobjectrequiredstatusstringrequiredOne of
"active""expired"expiresAtstring (date-time) | nullrequiredcreatedAtstring (date-time)required