Skip to main content
POST

Authorizations

Authorization
string
header
required

Timbal API key. Obtain your API key from the Timbal platform settings. See Authentication for more information.

Path Parameters

org_id
string
required

Body

application/json

Body for POST /orgs/{org_id}/metrics/definitions.

Every predicate field is optional and they AND together. All omitted means "every non-root span", which paired with label_source: span_name gives a per-step call count — a reasonable first definition.

metric_name
string
required

Destination metric. trace. is prepended when missing.

name
string
required

Human label for the definition itself, unique within the org.

has_error
boolean | null

true = only errored spans, false = only clean ones, omitted = both.

label_source
string

none (default) or span_name to break the metric out per step.

min_duration_ms
integer<int32> | null

Only spans at least this slow. Spans still running never match.

project_id
string | null

Scope to one project. Omit to apply across the org.

source
enum<string>

Defaults to trace_span, the only source today.

Available options:
trace_span
span_name
string | null

Exact span name — the leaf of the span path (llm, get_address), not the full {workforce}.{step}.

span_name_prefix
string | null

Span-name prefix, for matching a family of tools (get_).

status_code
string | null
value_source
string

count (default), duration_ms, or usage:<key>.

Response

Definition created

created_at
string<date-time>
required
enabled
boolean
required
id
integer<int64>
required
label_source
string
required

none or span_name.

metric_name
string
required
name
string
required
source
enum<string>
required

Always trace_span today; see [MetricDefinitionSource].

Available options:
trace_span
value_source
string
required

count, duration_ms, or usage:<key>.

has_error
boolean | null
min_duration_ms
integer<int32> | null
project_id
integer<int64> | null

Project scope; omitted when the filter applies to the whole org.

span_name
string | null
span_name_prefix
string | null
status_code
string | null