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.
Create a widget on a dashboard
Saves a React source file and the named LangWatchQL queries it runs as one widget, placed on this dashboard at the next free row. source records where the widget came from; without it, the widget is recorded as made through the API. Each query's sources lists the trace origins it counts; a query that names none counts ["application"].
Try this endpoint
app.langwatch.ai
API key · X-Auth-Token
Kept in this tab. Cleared when you reload.
This sends a live request to app.langwatch.ai.
Request and response examples
import osimport requestsorigin = "https://app.langwatch.ai"path = "/api/v1/dashboards/<dashboardId>/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())const url = "https://app.langwatch.ai/api/v1/dashboards/<dashboardId>/widgets";const response = await fetch(url, { method: "POST", headers: { "X-Auth-Token": 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/dashboards/<dashboardId>/widgets' \ --header "X-Auth-Token: $LANGWATCH_API_KEY" \ --header 'Content-Type: application/json' \ --data '{}'Call the LangWatch API from this project: Create a widget on a dashboard.Request: POST https://app.langwatch.ai/api/v1/dashboards/<dashboardId>/widgetsReference: https://langwatch.ai/docs/api-reference/dashboards/create-a-widget-on-a-dashboard.mdAuthentication: send the X-Auth-Token header, 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.The widget was saved on the dashboard
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}Bad Request
application/json · Generated from schema
{ "type": "string", "code": "string", "message": "string", "retryable": false, "meta": {}, "trace_id": "string", "span_id": "string", "trace": { "traceId": "string", "spanId": "string", "traceUrl": "string", "logsUrl": "string" }, "tips": [ "string" ], "docs_url": "string", "fault": "customer", "reasons": [ null ]}Unauthorized
application/json · Generated from schema
{ "type": "string", "code": "string", "message": "string", "retryable": false, "meta": {}, "trace_id": "string", "span_id": "string", "trace": { "traceId": "string", "spanId": "string", "traceUrl": "string", "logsUrl": "string" }, "tips": [ "string" ], "docs_url": "string", "fault": "customer", "reasons": [ null ]}Forbidden
application/json · Generated from schema
{ "type": "string", "code": "string", "message": "string", "retryable": false, "meta": {}, "trace_id": "string", "span_id": "string", "trace": { "traceId": "string", "spanId": "string", "traceUrl": "string", "logsUrl": "string" }, "tips": [ "string" ], "docs_url": "string", "fault": "customer", "reasons": [ null ]}No dashboard with this id for this key. A dashboard made by POST /api/v1/analytics/reports is an Analytics Report and is not found here.
application/json · Generated from schema
{ "type": "string", "code": "string", "message": "string", "retryable": false, "meta": {}, "trace_id": "string", "span_id": "string", "trace": { "traceId": "string", "spanId": "string", "traceUrl": "string", "logsUrl": "string" }, "tips": [ "string" ], "docs_url": "string", "fault": "customer", "reasons": [ null ]}Internal Server Error
application/json · Generated from schema
{ "type": "string", "code": "string", "message": "string", "retryable": false, "meta": {}, "trace_id": "string", "span_id": "string", "trace": { "traceId": "string", "spanId": "string", "traceUrl": "string", "logsUrl": "string" }, "tips": [ "string" ], "docs_url": "string", "fault": "customer", "reasons": [ null ]}Path parameters
dashboardIdstringrequiredRequest body
application/json · Required
namestringrequiredcodestringrequiredqueriesobject[]requireddescriptionstringpromptstringsourceobjectResponses
201The widget was saved on the dashboard
application/json
idstringrequirednamestringrequireddefinitionobjectrequiredcreatedAtstringrequiredupdatedAtstringrequiredplatformUrlstringrequireddashboardIdstring | nullrequiredgridColumnintegerrequiredgridRowintegerrequiredcolSpanintegerrequiredrowSpanintegerrequired400Bad Request
application/json
typestringrequiredcodestringrequiredmessagestringrequiredretryablebooleanrequiredmetaobjecttrace_idstringspan_idstringtraceobjecttipsstring[]docs_urlstringfaultstring"customer""platform""provider""presumed_platform"reasonsany[]401Unauthorized
application/json
typestringrequiredcodestringrequiredmessagestringrequiredretryablebooleanrequiredmetaobjecttrace_idstringspan_idstringtraceobjecttipsstring[]docs_urlstringfaultstring"customer""platform""provider""presumed_platform"reasonsany[]403Forbidden
application/json
typestringrequiredcodestringrequiredmessagestringrequiredretryablebooleanrequiredmetaobjecttrace_idstringspan_idstringtraceobjecttipsstring[]docs_urlstringfaultstring"customer""platform""provider""presumed_platform"reasonsany[]404No dashboard with this id for this key. A dashboard made by POST /api/v1/analytics/reports is an Analytics Report and is not found here.
application/json
typestringrequiredcodestringrequiredmessagestringrequiredretryablebooleanrequiredmetaobjecttrace_idstringspan_idstringtraceobjecttipsstring[]docs_urlstringfaultstring"customer""platform""provider""presumed_platform"reasonsany[]500Internal Server Error
application/json
typestringrequiredcodestringrequiredmessagestringrequiredretryablebooleanrequiredmetaobjecttrace_idstringspan_idstringtraceobjecttipsstring[]docs_urlstringfaultstring"customer""platform""provider""presumed_platform"reasonsany[]