Record a metric reading
ledger_metrics_record_readingRecord one observation of a tracked metric. metricId accepts a metric id OR its snake_case slug from ledger_metrics_list; an unknown one is a not_found error — check ledger_metrics_list, create it with ledger_metrics_create, or pass createIfMissing: true to mint a "measure" metric at that slug in the same call (an "event" metric when the reading carries labels). The reading automatically lands as evidence on every open decision whose prediction is bound to this metric — so when a user reports a number ("triage is down to 12 minutes"), offer to record it. For event-kind metrics, omit value to count one occurrence. May return needs_confirmation.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| at | No | ISO timestamp the reading is for. Defaults to now; set it when backfilling an earlier reading. | |
| key | No | Idempotency key (e.g. "2026-w32") — a repeat write with the same key returns the original reading instead of doubling the series. Use for scheduled/recurring recordings. The key is per set of labels, so one key per day can cover every country. | |
| note | No | Where the number came from, if worth recording. | |
| value | No | The observed value, in the metric's unit. Omit for event-kind metrics to record one occurrence. | |
| labels | No | Event metrics only. What this count is broken down by, e.g. { country: "DE", plan: "pro" } — snake_case names, string values. Lets the metric be read and claimed by slice later. Refused on a measure. | |
| metricId | Yes | Metric id or slug (from ledger_metrics_list). | |
| workspace | No | Workspace slug. Personal tokens with no default workspace MUST pass this; tokens with a default can override per call. Ignored for workspace API keys. | |
| approvalId | No | ||
| createIfMissing | No | Mint the metric when the slug is unknown. Default false — an unknown slug is an error, so a typo can't quietly start a second series. |