Skip to main content

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​

MethodDescription
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​

ParameterTypeRequiredDefaultDescription
userIdnumberYes--Target customer id (positional argument)
enabledbooleanYes--true to enable recording, false to disable (positional argument)

Response​

Returns boolean — true on success.

Errors​

CodeExceptionWhen
2007PermissionErrorAdmin lacks Context Management permission
3001AuthenticationErrorSession 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​

ParameterTypeRequiredDefaultDescription
userIdnumberYes--Target customer id
startDatestringNo--Range start (YYYY-MM-DD)
endDatestringNo--Range end (YYYY-MM-DD)
traceIdFilterstringNo--Filter by trace id
apiKeyIdnumberNo--Filter by API key id
maxTracesnumberNo--Max traces to return

Response​

Returns an object with entries, totalEntries, totalBytes, truncated.

Errors​

CodeExceptionWhen
2007PermissionErrorAdmin lacks Context Management permission
3001AuthenticationErrorSession 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​

ParameterTypeRequiredDefaultDescription
uidnumberYes--Target customer id
partitionDatestringYes--Record partition date (YYYY-MM-DD)
traceIdstringYes--Trace id of the record
visibilitystringYes--Record visibility scope

Response​

Returns an object with traceId, uid, visibility, inputJson, outputJsonl.

Errors​

CodeExceptionWhen
2007PermissionErrorAdmin lacks Context Management permission
3001AuthenticationErrorSession expired and refresh failed
Server 4xxWltErrorNo record matches the given traceId / partitionDate