import requests
url = "https://app.langwatch.ai/api/v1/grants"
payload = {
"principal": { "id": "<string>" },
"roleId": "<string>",
"scope": { "id": "<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({principal: {id: '<string>'}, roleId: '<string>', scope: {id: '<string>'}})
};
fetch('https://app.langwatch.ai/api/v1/grants', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://app.langwatch.ai/api/v1/grants \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"principal": {
"id": "<string>"
},
"roleId": "<string>",
"scope": {
"id": "<string>"
}
}
'{
"id": "<string>",
"principal": {
"type": "user",
"id": "<string>",
"name": "<string>"
},
"role": {
"id": "<string>",
"name": "<string>",
"builtIn": true
},
"scope": {
"type": "organization",
"id": "<string>",
"name": "<string>"
},
"status": "active",
"expiresAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z"
}Grant a role
Grant a role to a user, group or API key on the organization, a team or a project. roleId is admin, member, viewer or a custom role’s id. Grants are never unique: each create is a new grant with its own id, up to the organization’s limit (409 grant_limit_reached). Pass expiresAt to time-box the access. Send Idempotency-Key to make a retry safe. A grant never confers a permission the caller does not hold at that scope: 403 grant_exceeds_caller_permissions names the missing permissions.
import requests
url = "https://app.langwatch.ai/api/v1/grants"
payload = {
"principal": { "id": "<string>" },
"roleId": "<string>",
"scope": { "id": "<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({principal: {id: '<string>'}, roleId: '<string>', scope: {id: '<string>'}})
};
fetch('https://app.langwatch.ai/api/v1/grants', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://app.langwatch.ai/api/v1/grants \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"principal": {
"id": "<string>"
},
"roleId": "<string>",
"scope": {
"id": "<string>"
}
}
'{
"id": "<string>",
"principal": {
"type": "user",
"id": "<string>",
"name": "<string>"
},
"role": {
"id": "<string>",
"name": "<string>",
"builtIn": true
},
"scope": {
"type": "organization",
"id": "<string>",
"name": "<string>"
},
"status": "active",
"expiresAt": "2023-11-07T05:31:56Z",
"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}.
Headers
A caller-chosen key, 8 to 255 characters, that makes this create safe to retry. The first request to use a key runs normally and its response is stored for 24 hours. A later request with the same key and the same body is not executed again: it returns the stored response, marked with X-Idempotent-Replay: true. The same key with a different body is refused 409 idempotency_error, as is a retry sent while the original is still running. Only successful responses are stored, so a create that failed can simply be retried with the same key.
8 - 255Body
Response
Success
Was this page helpful?