import requests
url = "https://app.langwatch.ai/api/v1/projects/{projectId}/analytics/dashboard-widgets"
payload = {
"name": "<string>",
"code": "<string>",
"queries": [
{
"name": "<string>",
"sql": "<string>",
"parameters": [
{
"name": "<string>",
"default": "<string>"
}
]
}
]
}
headers = {
"X-Auth-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Auth-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
code: '<string>',
queries: [
{
name: '<string>',
sql: '<string>',
parameters: [{name: '<string>', default: '<string>'}]
}
]
})
};
fetch('https://app.langwatch.ai/api/v1/projects/{projectId}/analytics/dashboard-widgets', 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/projects/{projectId}/analytics/dashboard-widgets \
--header 'Content-Type: application/json' \
--header 'X-Auth-Token: <api-key>' \
--data '
{
"name": "<string>",
"code": "<string>",
"queries": [
{
"name": "<string>",
"sql": "<string>",
"parameters": [
{
"name": "<string>",
"default": "<string>"
}
]
}
]
}
'{
"id": "<string>",
"name": "<string>",
"definition": {
"version": 123,
"code": "<string>",
"queries": [
{
"name": "<string>",
"sql": "<string>",
"parameters": [
{
"name": "<string>",
"type": "string",
"default": "<string>"
}
]
}
],
"description": "<string>",
"prompt": "<string>",
"source": {
"kind": "catalogue",
"catalogueId": "<string>"
}
},
"createdAt": "<string>",
"updatedAt": "<string>",
"platformUrl": "<string>",
"dashboardId": "<string>",
"gridColumn": 0,
"gridRow": 0,
"colSpan": 0,
"rowSpan": 0
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"retryable": true,
"meta": {},
"trace_id": "<string>",
"span_id": "<string>",
"trace": {
"traceId": "<string>",
"spanId": "<string>",
"traceUrl": "<string>",
"logsUrl": "<string>"
},
"tips": [
"<string>"
],
"docs_url": "<string>",
"fault": "customer",
"reasons": [
"<unknown>"
]
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"retryable": true,
"meta": {},
"trace_id": "<string>",
"span_id": "<string>",
"trace": {
"traceId": "<string>",
"spanId": "<string>",
"traceUrl": "<string>",
"logsUrl": "<string>"
},
"tips": [
"<string>"
],
"docs_url": "<string>",
"fault": "customer",
"reasons": [
"<unknown>"
]
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"retryable": true,
"meta": {},
"trace_id": "<string>",
"span_id": "<string>",
"trace": {
"traceId": "<string>",
"spanId": "<string>",
"traceUrl": "<string>",
"logsUrl": "<string>"
},
"tips": [
"<string>"
],
"docs_url": "<string>",
"fault": "customer",
"reasons": [
"<unknown>"
]
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"retryable": true,
"meta": {},
"trace_id": "<string>",
"span_id": "<string>",
"trace": {
"traceId": "<string>",
"spanId": "<string>",
"traceUrl": "<string>",
"logsUrl": "<string>"
},
"tips": [
"<string>"
],
"docs_url": "<string>",
"fault": "customer",
"reasons": [
"<unknown>"
]
}Create a dashboard widget
Saves a React source file and the named LangWatchQL queries it runs as one dashboard widget, with an optional description the card shows behind its info icon and an optional prompt Langy is drafted with when asked about it. source records where the widget came from; without it, the widget is recorded as made through the API. The queries’ shape is validated against the widget schema; their SQL is governed at run time by LW.query inside the sandbox, not at save.
import requests
url = "https://app.langwatch.ai/api/v1/projects/{projectId}/analytics/dashboard-widgets"
payload = {
"name": "<string>",
"code": "<string>",
"queries": [
{
"name": "<string>",
"sql": "<string>",
"parameters": [
{
"name": "<string>",
"default": "<string>"
}
]
}
]
}
headers = {
"X-Auth-Token": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Auth-Token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
code: '<string>',
queries: [
{
name: '<string>',
sql: '<string>',
parameters: [{name: '<string>', default: '<string>'}]
}
]
})
};
fetch('https://app.langwatch.ai/api/v1/projects/{projectId}/analytics/dashboard-widgets', 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/projects/{projectId}/analytics/dashboard-widgets \
--header 'Content-Type: application/json' \
--header 'X-Auth-Token: <api-key>' \
--data '
{
"name": "<string>",
"code": "<string>",
"queries": [
{
"name": "<string>",
"sql": "<string>",
"parameters": [
{
"name": "<string>",
"default": "<string>"
}
]
}
]
}
'{
"id": "<string>",
"name": "<string>",
"definition": {
"version": 123,
"code": "<string>",
"queries": [
{
"name": "<string>",
"sql": "<string>",
"parameters": [
{
"name": "<string>",
"type": "string",
"default": "<string>"
}
]
}
],
"description": "<string>",
"prompt": "<string>",
"source": {
"kind": "catalogue",
"catalogueId": "<string>"
}
},
"createdAt": "<string>",
"updatedAt": "<string>",
"platformUrl": "<string>",
"dashboardId": "<string>",
"gridColumn": 0,
"gridRow": 0,
"colSpan": 0,
"rowSpan": 0
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"retryable": true,
"meta": {},
"trace_id": "<string>",
"span_id": "<string>",
"trace": {
"traceId": "<string>",
"spanId": "<string>",
"traceUrl": "<string>",
"logsUrl": "<string>"
},
"tips": [
"<string>"
],
"docs_url": "<string>",
"fault": "customer",
"reasons": [
"<unknown>"
]
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"retryable": true,
"meta": {},
"trace_id": "<string>",
"span_id": "<string>",
"trace": {
"traceId": "<string>",
"spanId": "<string>",
"traceUrl": "<string>",
"logsUrl": "<string>"
},
"tips": [
"<string>"
],
"docs_url": "<string>",
"fault": "customer",
"reasons": [
"<unknown>"
]
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"retryable": true,
"meta": {},
"trace_id": "<string>",
"span_id": "<string>",
"trace": {
"traceId": "<string>",
"spanId": "<string>",
"traceUrl": "<string>",
"logsUrl": "<string>"
},
"tips": [
"<string>"
],
"docs_url": "<string>",
"fault": "customer",
"reasons": [
"<unknown>"
]
}{
"type": "<string>",
"code": "<string>",
"message": "<string>",
"retryable": true,
"meta": {},
"trace_id": "<string>",
"span_id": "<string>",
"trace": {
"traceId": "<string>",
"spanId": "<string>",
"traceUrl": "<string>",
"logsUrl": "<string>"
},
"tips": [
"<string>"
],
"docs_url": "<string>",
"fault": "customer",
"reasons": [
"<unknown>"
]
}Authorizations
Project API key for sending traces and accessing project-scoped resources. Format: sk-lw-... (no underscore). Obtain one by creating a project via the Admin API or the LangWatch UI.
Path Parameters
1Body
1 - 2001 - 2000008Show child attributes
Show child attributes
1 - 20001 - 2000- Option 1
- Option 2
- Option 3
- Option 4
Show child attributes
Show child attributes
Response
The widget was saved
Show child attributes
Show child attributes
-9007199254740991 <= x <= 9007199254740991-9007199254740991 <= x <= 9007199254740991-9007199254740991 <= x <= 9007199254740991-9007199254740991 <= x <= 9007199254740991Was this page helpful?