Web Request Source Reference¶
This page is the full contract between an Insight custom widget and your endpoint:
- every setting on the Web Request source and on the widget;
- the exact request KnowledgeLake sends;
- the JSON each widget type expects back.
For the concepts and the rules, start with the Introduction.
At a glance
- Two calls
GET {Endpoint URL}/validatewhen an administrator tests or saves the source, andGET {Endpoint URL}/{API Relative Path}each time a widget loads. - Auth
Authorization: Bearer <token>, with the token from the source. Nothing else proves the call came from KnowledgeLake. - Body back JSON with
version,type,data.valuesand an optionalbrowserCacheTTL. KnowledgeLake validates it against the Custom Insight schema before the widget sees it. - Who calls The KnowledgeLake server, not the viewer's browser. CORS does not apply.
Summary¶
| Piece | Where it lives | Jump to |
|---|---|---|
| Endpoint URL, Bearer Token, Timeout | The Web Request source, in Connections > Sources | Source settings |
| WebRequest Connector, API Relative Path, Title | The widget's Custom Insight Settings box, in Insight | Widget settings |
Time Range (sent as Days-To-Include) |
Custom Time Series widget settings | Time Series settings |
| Display settings | Widget settings. They change only how the browser draws the data. | Widget settings |
/validate and data requests |
Sent by the KnowledgeLake server | The request |
| Response JSON | Returned by your endpoint | The response |
| Response schema | Served by your tenant at /api/CustomInsightExample/CustomInsightSchema |
Reference endpoints |
Web Request source settings¶
An administrator creates the source once:
- Go to Connections > Sources > Add a Source.
- Set Source Type to Web Request and enter a Source Name.
- Fill in the settings below.
SAVE runs Test Connection first and saves only when it passes. Creating or changing a source needs the Connections feature Edit Configuration.
Endpoint URL¶
The base URL of your endpoint. Every request goes to this URL or to a path under it.
- Type string, required
- Format An absolute
http://orhttps://URL. Use HTTPS: the token travels in a header. - Behavior KnowledgeLake adds a trailing slash before it resolves paths, so
https://host/api/insightandhttps://host/api/insight/behave the same. - Hosts The host must resolve to public addresses only. See Security.
- Example
https://your-function-app.azurewebsites.net/api/insight
Bearer Token¶
The secret KnowledgeLake sends as Authorization: Bearer <token> on every request, including /validate.
- Type string, required
- Storage An encrypted (secure) setting
- Behavior Your endpoint compares it with its own copy.
- Advice Generate a long random value (32 bytes or more). Keep your copy in your platform's secret store.
- Example header
Authorization: Bearer 7f3c9a...
Timeout (seconds)¶
How long KnowledgeLake waits for your endpoint before it gives up.
- Type integer, required
- Default
30. Must be greater than zero. - Behavior Applies to Test Connection and to every widget request.
- Covers The whole request, including reading your response body.
Test Connection¶
Sends GET {Endpoint URL}/validate with only the Authorization header and the configured Timeout. The source passes only when your endpoint returns exactly HTTP 200.
| Message on the source page | Cause |
|---|---|
An endpoint URL is required. |
Endpoint URL is empty. |
Enter a valid HTTP or HTTPS URL. |
The URL is not absolute, or the scheme is not http or https. |
A bearer token is required. |
Bearer Token is empty. |
Enter a timeout greater than zero seconds. |
Timeout is 0 or negative. |
The endpoint rejected the bearer token (401/403). Check the token and try again. |
/validate returned 401 or 403. |
The endpoint did not return a 200 OK response. |
/validate returned any other status, including 204 and 404. |
The request to the endpoint timed out. |
No answer within Timeout. KnowledgeLake also shows this text, at once, when the host does not resolve or resolves to a local or private address. |
The endpoint could not be reached. |
The host resolved but the request failed: an untrusted TLS certificate or a refused connection. |
Widget settings¶
A dashboard author adds the widget:
- Go to Insight > Dashboards and open a dashboard (or Actions > New Dashboard).
- Switch to Edit Mode.
- Drag a widget from the Custom group of the toolbox.
- Open Edit Widget.
The settings below are in the Custom Insight Settings box. Saving a dashboard needs the Insight feature Create Dashboards.
The panel also links to three references served by your tenant: API Contract (OpenAPI), View Example JSON and View Schema.
WebRequest Connector¶
The Web Request source this widget calls.
- Type Choice of the tenant's Web Request sources, required
- Not chosen The widget shows a "Not configured" message that asks you to select a WebRequest connector.
- No sources The list reads
No WebRequest connectors are configured. Add one in the Connections app.
API Relative Path¶
The path KnowledgeLake appends to the Endpoint URL for this widget.
- Type string, optional. Empty means the Endpoint URL itself.
- Behavior Resolved under the Endpoint URL. A leading slash is ignored. A query string is kept.
- Absolute URL refused. The widget shows the "could not be reached" error.
- Example
exceptions-breakdown?groupBy=vendor&top=8
Title (optional)¶
The widget title. When empty, the widget uses its type name (Custom Text, Custom Time Series or Custom Categorical).
Custom Text display settings¶
- Render Mode Plain Text or Markdown.
- Plain Text adds Text Alignment and Font Weight.
- Both modes Font Size and Text Color.
- Markdown Supports headings, bold, italic, links, lists, tables and code. Raw HTML in your text is not rendered.
Custom Time Series display settings¶
- Time Range Last 7, 14, 30, 60 or 90 Days. Default 30. This is the only display setting KnowledgeLake sends to your endpoint, as
Days-To-Include. - Display Mode Line Chart, Table or Summary (totals and averages).
- Missing Days Zero-fill, Gap, Hold or Average. Affects only the daily line chart.
- Time Grouping Daily, Weekly (14 days or more) or Monthly (30 days or more). Weekly and Monthly add up the daily values.
- Visualize Data Per Period or Cumulative.
- Get Available Series and Visible Series: the button asks your endpoint for
data.seriesand selects the first two names. Choose others, or clear the list to show all series. - Y-Axis One axis per series, or Use a single shared y-axis for all series with an optional axis title.
Custom Categorical display settings¶
- Display Pie Chart or Table.
- Table columns Category and Value.
The request KnowledgeLake sends¶
sequenceDiagram
participant Browser
participant KL as KnowledgeLake
participant EP as YourEndpoint
participant DB as YourData
Browser->>KL: Open the dashboard
KL->>EP: GET Endpoint URL plus API Relative Path with Bearer token
EP->>DB: Query
DB-->>EP: Rows
EP-->>KL: 200 with Custom Insight JSON
KL->>KL: Validate against the schema
KL-->>Browser: Widget data with Cache-Control max-age
Connection test request¶
GET {Endpoint URL}/validate
The connection test. It runs when an administrator clicks Test Connection and again on SAVE.
- Headers
Authorization: Bearer <token>only. No KnowledgeLake headers. - Returns HTTP 200 when the token is valid. HTTP 401 when it is not. The body is ignored.
GET /api/insight/validate HTTP/1.1
Host: your-function-app.azurewebsites.net
Authorization: Bearer <token>
Widget data request¶
GET {Endpoint URL}/{API Relative Path}
The widget data request.
- Runs When a dashboard that contains the widget opens, and when an author saves the dashboard.
- Body none, and no added query parameter.
- Refresh There is no refresh interval. A viewer sees new data on the next load after the browser cache expires.
GET /api/insight/invoice-volume HTTP/1.1
Host: your-function-app.azurewebsites.net
Authorization: Bearer <token>
User-Agent: KnowledgeLake-WebRequestConnector/<version>
Creator-Token: <user token of the dashboard owner>
Viewer-Token: <user token of the viewer>
Dashboard-Id: 3f2b8c1e-5a4d-4c2e-9b7a-1d6e0f9a2c44
Dashboard-Name: AP Operations
Widget-Id: 8d1e4b7a-2c3f-4e5d-a6b7-c8d9e0f1a2b3
Days-To-Include: 30
| Header | Value |
|---|---|
Authorization |
Bearer <token>, from the source. |
User-Agent |
Starts with KnowledgeLake-WebRequestConnector. |
Creator-Token |
The user token of the dashboard's owner. |
Viewer-Token |
The user token of the person viewing the dashboard. |
Dashboard-Id |
The dashboard's GUID. |
Dashboard-Name |
The dashboard's name, with line breaks removed. |
Widget-Id |
The widget's GUID. |
Days-To-Include |
7, 14, 30, 60 or 90. Sent only by Custom Time Series widgets. |
Series-Query |
true. Sent only by Get Available Series. |
Read header names case-insensitively. KnowledgeLake asserts the token headers; your endpoint trusts them only as far as it trusts that the bearer token is secret.
How the URL is built¶
| Endpoint URL + API Relative Path | Request URL |
|---|---|
https://host/api/insight + open-exceptions |
https://host/api/insight/open-exceptions |
https://host/api/insight/ + /open-exceptions |
https://host/api/insight/open-exceptions |
https://host/api/insight + breakdown?groupBy=queue |
https://host/api/insight/breakdown?groupBy=queue |
https://host/api/insight + (empty) |
https://host/api/insight/ |
Get Available Series request¶
The Custom Time Series Get Available Series button sends the data request with these differences:
- Added headers
Series-Query: trueandDays-To-Include: 7. - Ids
Dashboard-IdandWidget-Idare00000000-0000-0000-0000-000000000000.Dashboard-Nameis empty. - Tokens
Creator-TokenandViewer-Tokenboth hold the author's token.
Your endpoint may answer with the full payload, or with data.series and an empty data.values. The response must still pass the schema.
The button lists data.series. If it is missing, the list is empty.
The response contract¶
Return HTTP 2xx with a JSON body. Any other status fails the widget. KnowledgeLake does not check the Content-Type header, but send application/json.
Envelope¶
Every widget type uses the same envelope.
| Field | Type | Required | Meaning |
|---|---|---|---|
version |
string | Yes | The schema version. Send "1.0". A number fails the schema. |
type |
string | Yes | customtext, customtimeseries or customcategorical. Send the type that matches the widget. |
data |
object | Yes | Holds values (array, required) and, for time series, series. |
browserCacheTTL |
integer | No | Seconds the viewer's browser keeps this result. Absent means 0 (no browser cache). |
KnowledgeLake sends browserCacheTTL back to the browser as Cache-Control: private, max-age=<seconds>.
Dates are strings in ISO 8601 UTC, for example 2026-10-07T00:00:00Z.
customtext¶
- Item shape
{ "date": string, "str": string }, both required - Shown The
strof the item with the newestdate, as Plain Text or Markdown - Empty array The widget stays on
Loading…. Return at least one item.
{
"version": "1.0",
"browserCacheTTL": 300,
"type": "customtext",
"data": {
"values": [
{
"date": "2026-10-07T14:05:00Z",
"str": "## 1,284 open exceptions\n\n37 are older than 5 days.\n\nUpdated 14:05 UTC"
}
]
}
}
customtimeseries¶
- Series list
data.series(array of strings, optional) lists the series names for Get Available Series. - Item shape A required
dateand one number per series, keyed by the series name - Lines The chart draws one line per key found in the rows.
- Numbers only Every key other than
datemust be a number. A string ornullfails the schema. Leave a key out instead of sendingnull. - One row per day Dated at midnight UTC. The widget matches rows to days by their UTC date and keeps only the days inside the Time Range.
- Same day twice The last row wins. The rows are not added together.
- Additive values Send counts or totals. Weekly, Monthly and Cumulative views add the daily values up.
{
"version": "1.0",
"browserCacheTTL": 600,
"type": "customtimeseries",
"data": {
"series": ["Received", "Posted", "On Hold"],
"values": [
{ "date": "2026-10-01T00:00:00Z", "Received": 132, "Posted": 118, "On Hold": 6 },
{ "date": "2026-10-02T00:00:00Z", "Received": 141, "Posted": 129, "On Hold": 4 },
{ "date": "2026-10-03T00:00:00Z", "Received": 0, "Posted": 0, "On Hold": 0 },
{ "date": "2026-10-04T00:00:00Z", "Received": 0, "Posted": 0, "On Hold": 0 },
{ "date": "2026-10-05T00:00:00Z", "Received": 156, "Posted": 140, "On Hold": 9 },
{ "date": "2026-10-06T00:00:00Z", "Received": 149, "Posted": 137, "On Hold": 5 },
{ "date": "2026-10-07T00:00:00Z", "Received": 120, "Posted": 98, "On Hold": 7 }
]
}
}
customcategorical¶
- Item shape
{ "date": string, "datapoints": [ { "title": string, "amount": number } ] } - Shown Only the item with the newest
date, with one slice or table row per datapoint - Types A
titlemust be a string (notnull). Anamountmust be a number.
{
"version": "1.0",
"browserCacheTTL": 300,
"type": "customcategorical",
"data": {
"values": [
{
"date": "2026-10-07T14:05:00Z",
"datapoints": [
{ "title": "Northwind Traders", "amount": 41 },
{ "title": "Contoso Supply", "amount": 30 },
{ "title": "Fabrikam", "amount": 12 },
{ "title": "Other", "amount": 9 }
]
}
]
}
}
Reference endpoints on your tenant¶
These need no sign-in. Open them in a browser, or point your tests at them.
| Path | Returns |
|---|---|
/api/CustomInsightExample/TextExample |
A sample customtext response |
/api/CustomInsightExample/TimeSeriesExample |
A sample customtimeseries response |
/api/CustomInsightExample/CategoricalExample |
A sample customcategorical response |
/api/CustomInsightExample/CustomInsightSchema |
The JSON Schema (draft-07) KnowledgeLake validates against |
/api/CustomInsightExample/OpenApiJson?domain=https://{tenant} |
An OpenAPI 3 contract for /validate and a data path |
/api/CustomInsightExample/OpenApiYaml?domain=https://{tenant} |
The same contract in YAML |
Security¶
- Server-side call. The KnowledgeLake server calls your endpoint. The viewer's browser never sees the URL or the token.
- Public hosts only. KnowledgeLake resolves the host when the source is saved and again on every request. If any address is loopback, private (
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16),0.0.0.0/8, link-local (169.254.0.0/16, which includes cloud metadata addresses), or IPv6 link-local or unique-local, the request is refused. - Same host only. The API Relative Path is appended to the Endpoint URL and cannot change the host or the scheme. Put only widget data on that host, and check the path in your endpoint.
- One token per source. Every widget on every dashboard that uses a source sends the same token. Any dashboard author can pick any Web Request source. Create a separate source and token for data that only some dashboards may show, or filter by
Viewer-Token. - Rotate the token. Change it on your endpoint and in the source at the same time. Until both match, Test Connection and the widgets fail with 401.
Endpoint skeleton¶
Every recipe on this site builds on these files: a helper that checks the token and wraps the envelope, and the /validate function.
- Endpoint URL The routes assume
https://{function-app}.azurewebsites.net/api/insight. - App settings
InsightBearerToken(the same value as the source's Bearer Token) and, for the recipes,SqlConnectionString.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
</ItemGroup>
</Project>
using Microsoft.Extensions.Hosting;
var host = new HostBuilder()
.ConfigureFunctionsWebApplication()
.Build();
host.Run();
using System.Globalization;
using System.Security.Cryptography;
using System.Text;
using System.Text.Json.Nodes;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace InsightWidgets;
public static class InsightHelpers
{
// True when the request carries "Authorization: Bearer <token>" and the token
// equals the InsightBearerToken app setting. The comparison takes constant time.
public static bool IsAuthorized(HttpRequest req)
{
string expected = Environment.GetEnvironmentVariable("InsightBearerToken") ?? "";
string header = req.Headers.Authorization.ToString();
const string prefix = "Bearer ";
if (expected.Length == 0 || !header.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
{
return false;
}
byte[] presented = Encoding.UTF8.GetBytes(header.Substring(prefix.Length).Trim());
byte[] wanted = Encoding.UTF8.GetBytes(expected);
return CryptographicOperations.FixedTimeEquals(presented, wanted);
}
// The envelope every Custom Insight response uses.
public static JsonObject Envelope(string type, JsonObject data, int browserCacheTtlSeconds)
{
return new JsonObject
{
["version"] = "1.0",
["browserCacheTTL"] = browserCacheTtlSeconds,
["type"] = type,
["data"] = data
};
}
public static IActionResult Json(JsonObject body)
{
return new ContentResult
{
Content = body.ToJsonString(),
ContentType = "application/json",
StatusCode = 200
};
}
// ISO 8601 UTC timestamp, for example 2026-10-07T14:05:00Z.
public static string IsoUtc(DateTime utc)
{
return utc.ToString("yyyy-MM-dd'T'HH:mm:ss'Z'", CultureInfo.InvariantCulture);
}
}
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Functions.Worker;
namespace InsightWidgets;
public class Validate
{
// Test Connection calls GET {Endpoint URL}/validate. Return 200 only for the right token.
[Function("Validate")]
public IActionResult Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "insight/validate")] HttpRequest req)
{
return InsightHelpers.IsAuthorized(req) ? new OkResult() : new UnauthorizedResult();
}
}
JsonObject keeps property names exactly as written, so a series name such as On Hold reaches the widget unchanged. If you return a C# object through OkObjectResult instead, ASP.NET Core applies its camelCase naming policy and renames the properties.
{
"name": "insight-widgets",
"version": "1.0.0",
"main": "src/functions/*.js",
"dependencies": {
"@azure/functions": "^4.0.0",
"mssql": "^12.0.0"
}
}
const crypto = require('crypto');
const sql = require('mssql');
// True when the request carries "Authorization: Bearer <token>" and the token
// equals the InsightBearerToken app setting. The comparison takes constant time.
function isAuthorized(request) {
const expected = process.env.InsightBearerToken || '';
const header = request.headers.get('authorization') || '';
if (!expected || !/^bearer /i.test(header)) {
return false;
}
const presented = Buffer.from(header.slice(7).trim());
const wanted = Buffer.from(expected);
return presented.length === wanted.length && crypto.timingSafeEqual(presented, wanted);
}
// The envelope every Custom Insight response uses.
function envelope(type, data, browserCacheTTL) {
return { version: '1.0', browserCacheTTL: browserCacheTTL, type: type, data: data };
}
// ISO 8601 UTC timestamp without milliseconds, for example 2026-10-07T14:05:00Z.
function isoUtc(date) {
return date.toISOString().slice(0, 19) + 'Z';
}
// One connection pool per function app instance.
let poolPromise = null;
function getPool() {
if (!poolPromise) {
poolPromise = sql.connect(process.env.SqlConnectionString).catch(function (err) {
poolPromise = null;
throw err;
});
}
return poolPromise;
}
module.exports = { isAuthorized, envelope, isoUtc, getPool, sql };
const { app } = require('@azure/functions');
const { isAuthorized } = require('../insight');
// Test Connection calls GET {Endpoint URL}/validate. Return 200 only for the right token.
app.http('Validate', {
methods: ['GET'],
authLevel: 'anonymous',
route: 'insight/validate',
handler: async function (request) {
return { status: isAuthorized(request) ? 200 : 401 };
}
});
Anonymous auth level
The functions use anonymous auth level because KnowledgeLake cannot send an Azure function key. The bearer check is the authentication. Keep InsightBearerToken in app settings or a Key Vault reference, never in code.
Related¶
- Introduction: the extension point, rules and gotchas
- Debugging Insight Widgets: every error message and its fix
- KPI: Open Exceptions: the smallest working widget
- Your Own Endpoint: the same hosting pattern for workflow calls