Admin Context — TypeScript SDK
Context-record toggle, listing, and body export for a customer.
Overview
The admin Context resource controls context recording for an end-customer and exports recorded entries. Toggle recording on or off, list recorded entries within a date range, and fetch the input/output payload of a single record.
Accessed via admin.context.
Available Operations
| Method | Description |
|---|---|
toggle() | Enable or disable context recording for a customer |
list() | List recorded context entries within a date range |
getBody() | Fetch a single record's input/output payload |
toggle
Enable or disable context recording for a customer.
Example Usage
const ok = await admin.context.toggle(42, true);
console.log(ok); // true
// Turn it back off
await admin.context.toggle(42, false);
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| userId | number | Yes | -- | Target customer id (positional argument) |
| enabled | boolean | Yes | -- | true to enable recording, false to disable (positional argument) |
Response
Returns boolean — true on success.
Errors
| Code | Exception | When |
|---|---|---|
2007 | PermissionError | Admin lacks Context Management permission |
3001 | AuthenticationError | Session expired and refresh failed |
list
List recorded context entries for a customer, optionally filtered by date range, trace id, or API key id.
Example Usage
const result = await admin.context.list({
userId: 42,
startDate: '2026-07-01',
endDate: '2026-07-14',
});
console.log(result.totalEntries, result.totalBytes, result.truncated);
for (const entry of result.entries) {
console.log(entry);
}
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| userId | number | Yes | -- | Target customer id |
| startDate | string | No | -- | Range start (YYYY-MM-DD) |
| endDate | string | No | -- | Range end (YYYY-MM-DD) |
| traceIdFilter | string | No | -- | Filter by trace id |
| apiKeyId | number | No | -- | Filter by API key id |
| maxTraces | number | No | -- | Max traces to return |
Response
Returns an object with entries, totalEntries, totalBytes, truncated.
Errors
| Code | Exception | When |
|---|---|---|
2007 | PermissionError | Admin lacks Context Management permission |
3001 | AuthenticationError | Session expired and refresh failed |
getBody
Fetch a single recorded context body (input/output payload).
Example Usage
const body = await admin.context.getBody({
uid: 42,
partitionDate: '2026-07-14',
traceId: 'trace-abc',
visibility: 'PLATFORM',
});
console.log(body.inputJson);
console.log(body.outputJsonl);
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| uid | number | Yes | -- | Target customer id |
| partitionDate | string | Yes | -- | Record partition date (YYYY-MM-DD) |
| traceId | string | Yes | -- | Trace id of the record |
| visibility | string | Yes | -- | Record visibility scope |
Response
Returns an object with traceId, uid, visibility, inputJson, outputJsonl.
Errors
| Code | Exception | When |
|---|---|---|
2007 | PermissionError | Admin lacks Context Management permission |
3001 | AuthenticationError | Session expired and refresh failed |
| Server 4xx | WltError | No record matches the given traceId / partitionDate |