Skip to contentSkip to page list

Docs

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.

POST/api/v1/projects/{projectId}/analytics/dashboard-widgets
Request and response examples
request.py
import osimport requests​origin = "https://app.langwatch.ai"path = "/api/v1/projects/<projectId>/analytics/dashboard-widgets"api_key = os.environ["LANGWATCH_API_KEY"]headers = {    "X-Auth-Token": api_key,    "Content-Type": "application/json",}payload = {}​response = requests.post(    origin + path,    headers=headers,    json=payload,)print(response.json())

The widget was saved

application/json · Generated from schema

{  "id": "string",  "name": "string",  "definition": {    "version": 0,    "code": "string",    "queries": [      {        "name": "string",        "sql": "string",        "parameters": [          {            "name": null,            "type": null,            "default": null          }        ],        "sources": [          null        ],        "projects": [          null        ]      }    ],    "description": "string",    "prompt": "string",    "source": {      "kind": "catalogue",      "catalogueId": "string"    }  },  "createdAt": "string",  "updatedAt": "string",  "platformUrl": "string",  "dashboardId": "string",  "gridColumn": -9007199254740991,  "gridRow": -9007199254740991,  "colSpan": -9007199254740991,  "rowSpan": -9007199254740991}
api-reference/projects/create-a-dashboard-widget

Authorization

X-Auth-Tokenstringheaderrequired

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

projectIdstringrequired
At least 1 character

Request body

application/json · Required

namestringrequired
At least 1 characterUp to 200 characters
codestringrequired
At least 1 characterUp to 200000 characters
queriesobject[]required
namestringrequired
At least 1 characterUp to 64 charactersPattern ^[A-Za-z_][A-Za-z0-9_]*$
sqlstringrequired
At least 1 characterUp to 50000 characters
parametersobject[]
sourcesstring[] | null
projectsstring[] | null
descriptionstring
At least 1 characterUp to 2000 characters
promptstring
At least 1 characterUp to 2000 characters
sourceobject
Option 1kind: "catalogue"object
kindstringrequired
Always"catalogue"
catalogueIdstringrequired
At least 1 characterUp to 200 characters
Option 2kind: "langy"object
kindstringrequired
Always"langy"
Option 3kind: "code"object
kindstringrequired
Always"code"
Option 4kind: "api"object
kindstringrequired
Always"api"

Responses

201

The widget was saved

application/json

idstringrequired
namestringrequired
definitionobjectrequired
versionnumberrequired
codestringrequired
queriesobject[]required
descriptionstring
promptstring
sourceobject
createdAtstringrequired
updatedAtstringrequired
platformUrlstringrequired
dashboardIdstring | nullrequired
gridColumnintegerrequired
Minimum -9007199254740991Maximum 9007199254740991
gridRowintegerrequired
Minimum -9007199254740991Maximum 9007199254740991
colSpanintegerrequired
Minimum -9007199254740991Maximum 9007199254740991
rowSpanintegerrequired
Minimum -9007199254740991Maximum 9007199254740991
400

Bad Request

application/json

typestringrequired
codestringrequired
messagestringrequired
retryablebooleanrequired
metaobject
trace_idstring
span_idstring
traceobject
traceIdstring
spanIdstring
traceUrlstring
logsUrlstring
tipsstring[]
docs_urlstring
faultstring
One of"customer""platform""provider""presumed_platform"
reasonsany[]
401

Unauthorized

application/json

typestringrequired
codestringrequired
messagestringrequired
retryablebooleanrequired
metaobject
trace_idstring
span_idstring
traceobject
traceIdstring
spanIdstring
traceUrlstring
logsUrlstring
tipsstring[]
docs_urlstring
faultstring
One of"customer""platform""provider""presumed_platform"
reasonsany[]
403

Forbidden

application/json

typestringrequired
codestringrequired
messagestringrequired
retryablebooleanrequired
metaobject
trace_idstring
span_idstring
traceobject
traceIdstring
spanIdstring
traceUrlstring
logsUrlstring
tipsstring[]
docs_urlstring
faultstring
One of"customer""platform""provider""presumed_platform"
reasonsany[]
500

Internal Server Error

application/json

typestringrequired
codestringrequired
messagestringrequired
retryablebooleanrequired
metaobject
trace_idstring
span_idstring
traceobject
traceIdstring
spanIdstring
traceUrlstring
logsUrlstring
tipsstring[]
docs_urlstring
faultstring
One of"customer""platform""provider""presumed_platform"
reasonsany[]

Documentation