Browse the API reference

Compute Metrics for a Metric Block

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

Part of Extensions: RoboLedger.

Resolves the Derive rules scoped to a metric block (block_type='metric'), binds each rule's operands to the entity's most recent persisted report facts at period_end, evaluates, and upserts the period's standing factset_type='metric' FactSet — one per (structure, entity, period_end), so successive runs accumulate the time series and re-running a period replaces its values. Metrics with missing operands or undefined ratios are skipped with a reason, never errored.

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 compute.

period_endrequiredstring (date)

Period end to compute at. Operands bind to report facts whose period_end matches exactly (instant balances as of this date; durations ending on it).

period_startoptionalstring (date)

Optional lower bound for duration-operand binding and the standing FactSet's period_start.

entity_idoptionalstring

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

scenario_idoptionalstring

Compute on a scenario slice: operands bind that scenario's facts (actuals as the fallback across the seam) and the standing metric set is stamped with the scenario. None (the default) computes actuals only. Pass a forecast block's structure id after compute-forecast to extend the metric series into its forward months.

Example request

curl
curl -X POST "https://api.robosystems.ai/extensions/roboledger/{graph_id}/operations/compute-metrics" \
  -H "X-API-Key: $ROBOSYSTEMS_API_KEY" \
  -H "Idempotency-Key: <Idempotency-Key>" \
  -H "Content-Type: application/json" \
  -d '{
  "period_end": "2026-03-31",
  "structure_id": "str_key_financial_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

resultoptionalComputeMetricsResponse

Command-specific result payload

ComputeMetricsResponse fields
FieldTypeDescription
structure_idrequiredstring
entity_idrequiredstring
period_endrequiredstring (date)
fact_set_idoptionalstring

Standing metric FactSet for the period — None when every metric was skipped and no prior set existed.

computedoptionalComputedMetricLite[]

One metric computed by a ``compute-metrics`` run.

ComputedMetricLite fields
FieldTypeDescription
rule_idrequiredstring

Derive rule that produced the value.

element_idrequiredstring

Metric element the fact was written for.

element_qnameoptionalstring

Metric element qname (e.g. rs-metric:CurrentRatio).

namerequiredstring

Metric display name.

valuerequirednumber

Computed 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.

skippedoptionalSkippedMetricLite[]

One metric a ``compute-metrics`` run could not compute. Soft-fail by design: a missing operand fact (e.g. InterestExpense for a debt-free entity) or an undefined ratio (division by zero) skips the metric with a reason — it never errors the run.

SkippedMetricLite fields
FieldTypeDescription
rule_idrequiredstring

Derive rule that was skipped.

element_qnameoptionalstring

Metric element qname the rule targets.

reasonrequiredstring

Why the metric was skipped.

missingoptionalstring[]

Operand qnames with no bound fact at the period, when applicable.

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