---
title: Token Event
---
```js
import {API} from "../components/config.js";
import {fieldRow} from "../components/field-help.js";
```
```js
const eventId = observable.params.id;
const raw = await fetch(`${API}/token-events/${eventId}`)
.then(r => r.ok ? r.json() : r.json().then(e => ({error: e.detail ?? `HTTP ${r.status}`})))
.catch(e => ({error: String(e)}));
```
```js
if (raw.error) {
display(html`
⚠️ ${raw.error}
`);
} else {
const shortId = raw.id ? raw.id.slice(0, 8) + "…" : eventId;
display(html`Token Event · ${shortId}
`);
display(html`← Token Cost
`);
const FIELD_ORDER = [
"id","measurement_kind","source_provider","source_id",
"tokens_in","tokens_out","tokens_total","token_evidence_total",
"cached_input_tokens","reasoning_output_tokens","raw_total_tokens",
"note","model","agent","session_id",
"task_id","workstream_id","repo_id",
"ref_type","ref_id","source_path","source_created_at",
"parser_version","confidence","ingested_at","created_at",
"raw_metadata",
];
const rows = FIELD_ORDER.map(k => fieldRow(k, raw[k] ?? null));
for (const k of Object.keys(raw)) {
if (!FIELD_ORDER.includes(k)) rows.push(fieldRow(k, raw[k]));
}
display(html``);
}
```