Browse the API reference

Assert Metrics for a Metric Block

post/extensions/roboledger/{graph_id}/operations/assert-metrics

Part of Extensions: RoboLedger.

Writes externally-observed metric values (usage counts, marketing numbers, hand-carried figures) into the period's standing factset_type='metric' FactSet with AssertedProvenance — the observation sibling of compute-metrics. One standing FactSet per (structure, entity, period_end); re-asserting a period replaces its facts. Structures carrying Derive rules are compute-owned and rejected: asserted and derived metric series keep disjoint structures. Observations must resolve to concepts on the structure's presentation catalog. Deterministic and non-AI — no credits consumed.

Idempotency: supply an Idempotency-Key header to make safe retries; replays within 24 hours return the same envelope. Reusing the key with a different body returns HTTP 409 Conflict.

Authentication

Authenticate in any one of these ways — not all of them:

  • API key in the X-API-Key header.
  • Bearer token in the Authorization header.

Path parameters

NameTypeDescription
graph_idrequiredstringGraph Id

Header parameters

NameTypeDescription
Idempotency-KeyoptionalstringIdempotency-Key

Request body

Required, application/json.

FieldTypeDescription
structure_idrequiredstring

Metric block structure (block_type='metric') to assert into.

period_endrequiredstring (date)

Period end the observations are for — instant concepts (a follower count at month end) land as of this date; duration concepts (monthly downloads) end on it.

period_startoptionalstring (date)

Window start for duration concepts and the standing FactSet's period_start. Instant concepts ignore it.

entity_idoptionalstring

Entity to assert for. Defaults to the graph's earliest-created entity (the primary entity for single-entity graphs).

source_systemrequiredstring

Identifier of the asserting system (e.g. 'content-machine') — recorded as the AssertedProvenance source_system.

basis_noteoptionalstring

Free-text basis / source reference for the observations.

observationsrequiredMetricObservation[]

Observed values, one per metric concept — duplicates rejected.

MetricObservation fields
FieldTypeDescription
qnamerequiredstring

Metric element qname (e.g. rsx:GithubStars). Must resolve to a concept on the structure's presentation catalog.

valuerequirednumber

Observed value.

Example request

curl
curl -X POST "https://api.robosystems.ai/extensions/roboledger/{graph_id}/operations/assert-metrics" \
  -H "X-API-Key: $ROBOSYSTEMS_API_KEY" \
  -H "Idempotency-Key: <Idempotency-Key>" \
  -H "Content-Type: application/json" \
  -d '{
  "observations": [
    {
      "qname": "rsx:GithubStars",
      "value": 1240
    },
    {
      "qname": "rsx:NpmDownloads",
      "value": 3811
    }
  ],
  "period_end": "2026-07-31",
  "period_start": "2026-07-01",
  "source_system": "content-machine",
  "structure_id": "str_growth_metrics"
}'

Responses

200 Successful Response

FieldTypeDescription
operationrequiredstring

Kebab-case operation name

operationIdrequiredstring

op_-prefixed ULID for audit and SSE correlation

statusrequiredstring

Operation lifecycle state

One of: completed, pending, failed

resultoptionalAssertMetricsResponse

Command-specific result payload

AssertMetricsResponse fields
FieldTypeDescription
structure_idrequiredstring
entity_idrequiredstring
period_endrequiredstring (date)
fact_set_idrequiredstring

Standing metric FactSet the observations were written to.

assertedoptionalAssertedMetricLite[]

One metric written by an ``assert-metrics`` run.

AssertedMetricLite fields
FieldTypeDescription
element_idrequiredstring

Metric element the fact was written for.

element_qnamerequiredstring

Metric element qname.

namerequiredstring

Metric display name.

valuerequirednumber

Asserted value.

unitrequiredstring

Fact unit — 'USD' for monetary, 'days' for days, else 'pure'.

period_typerequiredstring

'instant' or 'duration'.

item_typeoptionalstring

Format family from the metric element (monetary | ratio | percent | multiple | days). None means untyped; fall back to unit.

replacedoptionalboolean

True when a prior standing set existed for the period and its facts were replaced.

Default: false

atrequiredstring

ISO-8601 UTC timestamp

createdByoptionalstring

User ID that initiated the operation (null for legacy callers)

idempotentReplayoptionalboolean

True when this envelope came from the idempotency cache — the underlying command did not execute again. False on fresh executions.

Default: false

StatusMeaning
400Invalid request
401Authentication required
403Access denied
404Resource not found
409Idempotency-Key conflict — key reused with different body
422Validation error
429Rate limit exceeded
500Internal server error