Create a metric, or refine the one already holding this name for the team.
Request
- Base URL: https://us.posthog.com
- URL: https://us.posthog.com/api/projects/{project_id}/data_catalog/metrics/
- Auth: HTTP bearer
Path parameters
Project ID of the project you're trying to access. To find the ID of the project, make a call to /api/projects/.
Request body
Identifier-safe run handle, unique among the team's live metrics. Renaming or deleting a metric frees its name for reuse, and anything referencing the old name (SQL over information_schema.metrics, run URLs, links) stops resolving.
Human-friendly label. Mutable, unlike name.
What the number is, in 1-2 short sentences under 300 characters: its meaning and grain plus any inclusion or exclusion that changes it. Leave out source tables or views, lineage, column lists, and comparisons with other metrics. Never narrate the query - the definition carries the mechanics; put rationale for query choices in 'reasoning'.
Unit of the result, e.g. usd, percent, cents.
Email of the human accountable for this metric, or null.
Machine-readable query. Omit for a name+description-only stub. Stored upgrade-canonical.
Query kind of the definition (HogQLQuery, TrendsQuery, ...), or null for a stub.
Persisted lifecycle state: 'proposed' or 'approved'. Drift is reported separately.
True when the definition has drifted from its linked source insight (or the insight is gone).
Create the metric from this insight's query (snapshotted server-side). Set to null to unlink. Mutually exclusive with definition.
When the metric was last run (30-minute throttle).
- user - user
- ai_generated - ai_generated
Model that generated the metric, if AI-authored.
AI author's confidence in the proposal, 0-1.
AI author's reasoning, surfaced as review context.
Response
Identifier-safe run handle, unique among the team's live metrics. Renaming or deleting a metric frees its name for reuse, and anything referencing the old name (SQL over information_schema.metrics, run URLs, links) stops resolving.
Human-friendly label. Mutable, unlike name.
What the number is, in 1-2 short sentences under 300 characters: its meaning and grain plus any inclusion or exclusion that changes it. Leave out source tables or views, lineage, column lists, and comparisons with other metrics. Never narrate the query - the definition carries the mechanics; put rationale for query choices in 'reasoning'.
Unit of the result, e.g. usd, percent, cents.
Email of the human accountable for this metric, or null.
Machine-readable query. Omit for a name+description-only stub. Stored upgrade-canonical.
Query kind of the definition (HogQLQuery, TrendsQuery, ...), or null for a stub.
Persisted lifecycle state: 'proposed' or 'approved'. Drift is reported separately.
True when the definition has drifted from its linked source insight (or the insight is gone).
Create the metric from this insight's query (snapshotted server-side). Set to null to unlink. Mutually exclusive with definition.
When the metric was last run (30-minute throttle).
- user - user
- ai_generated - ai_generated
Model that generated the metric, if AI-authored.
AI author's confidence in the proposal, 0-1.
AI author's reasoning, surfaced as review context.
Changes
No recorded changes to this operation across all 1 revision of this API.