Skip to main content
POST
Create metric

Authorizations

Authorization
string
header
required

Path Parameters

projectKey
string<string>
required

The project key

Body

application/json
key
string
required

A unique key to reference the metric

Example:

"metric-key-123abc"

kind
enum<string>
required

The kind of event your metric will track

Available options:
pageview,
click,
custom,
trace
Example:

"custom"

name
string

A human-friendly name for the metric

Example:

"Example metric"

description
string

Description of the metric

Example:

"optional description"

selector
string

One or more CSS selectors. Required for click metrics only.

Example:

".dropdown-toggle"

urls
object[]

One or more target URLs. Required for click and pageview metrics only.

Example:

"invalid example"

isNumeric
boolean

Whether to track numeric changes in value against a baseline (true) or to track a conversion when an end user takes an action (false). Required for custom and trace metrics only.

Example:

false

unit
string

The unit of measure. Applicable for numeric custom and trace metrics only.

Example:

"orders"

eventKey
string

The event key to use in your code. Required for custom conversion/binary and custom numeric metrics only.

Example:

"Order placed"

successCriteria
enum<string>

Success criteria. Required for custom and trace numeric metrics, optional for custom and trace conversion metrics.

Available options:
HigherThanBaseline,
LowerThanBaseline
Example:

"HigherThanBaseline"

tags
string[]

Tags for the metric

Example:
randomizationUnits
string[]
deprecated

Deprecated, use analysisUnits instead.

Example:
analysisUnits
string[]

An array of analysis units allowed for this metric.

Example:
maintainerId
string

The ID of the member who maintains this metric

Example:

"569fdeadbeef1644facecafe"

unitAggregationType
enum<string>

The method by which multiple unit event values are aggregated

Available options:
average,
sum,
count_distinct
Example:

"average"

analysisType
string

The method for analyzing metric events

Example:

"mean"

percentileValue
integer

The percentile for the analysis method. An integer denoting the target percentile between 0 and 100. Required when analysisType is percentile.

Example:

95

eventDefault
object
dataSource
object
filters
object

Filters for the metric to exclude certain events from being included. This is only supported for custom metrics.

windowStartOffset
integer<int64>

Not yet implemented - The start of the measurement window, in milliseconds relative to the unit's first exposure to a flag variation

windowEndOffset
integer<int64>

Not yet implemented - The end of the measurement window, in milliseconds relative to the unit's first exposure to a flag variation

winsorLowerPercentile
number

Lower winsorization percentile, expressed as a percent in the open interval (0, 100). When both bounds are set, defines a two-sided clamp range. Otherwise lower-only winsorization.

Example:

1

winsorUpperPercentile
number

Upper winsorization percentile, expressed as a percent in the open interval (0, 100). When both bounds are set, must be greater than winsorLowerPercentile.

Example:

99.5

winsorIncludeImputed
boolean

When true, the percentile bound calculation includes imputed zeros. Only meaningful when at least one bound is set and the metric includes units that didn't send events.

Example:

false

traceQuery
string

The trace query to use for the metric. Required for trace metrics.

Example:

"service.name = \"checkout\""

traceValueLocation
string

The location in the trace to use for numeric values. Required for numeric trace metrics.

Example:

"duration"

unitAggregationField
string

The warehouse column to use for counting distinct values. Required when the unitAggregationType is count_distinct.

valueColumn
string

For numeric warehouse-native metrics, the column holding the numeric value. Overrides the value column mapped on the data source.

denominator
object

For ratio metrics, the denominator event configuration. Only supported for warehouse native custom metrics.

Response

Metric response

_id
string
required

The ID of this metric

Example:

"5902deadbeef667524a01290"

_versionId
string
required

The version ID of the metric

Example:

"version-id-123abc"

key
string
required

A unique key to reference the metric

Example:

"metric-key-123abc"

name
string
required

A human-friendly name for the metric

Example:

"My metric"

kind
enum<string>
required

The kind of event the metric tracks

Available options:
pageview,
click,
custom,
trace
Example:

"custom"

The location and content type of related resources

Example:
tags
string[]
required

Tags for the metric

Example:
_creationDate
integer<int64>
required

Timestamp of when the metric was created

Example:

"1628192791148"

dataSource
object
required
experimentCount
integer

The number of experiments using this metric

Example:

0

metricGroupCount
integer

The number of metric groups using this metric

Example:

0

activeExperimentCount
integer

The number of active experiments using this metric

Example:

2

activeGuardedRolloutCount
integer

The number of active guarded rollouts using this metric

Example:

1

_version
integer

Version of the metric

Example:

1

_attachedFlagCount
integer

The number of feature flags currently attached to this metric

Example:

0

_site
object

Details on how to access the metric in the LaunchDarkly UI

Example:

"{\"href\":\"/my-project/metrics/my-metric/details\",\"type\":\"text/html\"}"

_access
object

Details on the allowed and denied actions for this metric

lastModified
object
maintainerId
string

The ID of the member who maintains this metric

Example:

"569fdeadbeef1644facecafe"

_maintainer
object

Details on the member who maintains this metric

Example:

"{\"_links\":{\"self\":{\"href\":\"/api/v2/members/569fdeadbeef1644facecafe\",\"type\":\"application/json\"}},\"_id\":\"569fdeadbeef1644facecafe\",\"firstName\":\"Ariel\",\"lastName\":\"Flores\",\"role\":\"owner\",\"email\":\"ariel@acme.com\"}"

description
string

Description of the metric

category
string

The category of the metric

Example:

"Error monitoring"

isNumeric
boolean

For custom and trace metrics, whether to track numeric changes in value against a baseline (true) or to track a conversion when an end user takes an action (false).

Example:

true

successCriteria
enum<string>

For custom and trace metrics, the success criteria

Available options:
HigherThanBaseline,
LowerThanBaseline
unit
string

For numeric custom and trace metrics, the unit of measure

eventKey
string

For custom metrics, the event key to use in your code

Example:

"Order placed"

randomizationUnits
string[]
deprecated

Deprecated, use analysisUnits instead.

Example:
analysisUnits
string[]

An array of analysis units allowed for this metric.

Example:
filters
object

The filters narrowing down the audience based on context attributes or event properties.

Example:

"{\"type\":\"group\",\"op\":\"and\",\"values\":[{\"type\":\"contextAttribute\",\"op\":\"in\",\"contextKind\":\"user\",\"attribute\":\"country\",\"values\":[\"JP\"],\"negate\":false},{\"type\":\"eventProperty\",\"op\":\"in\",\"attribute\":\"category\",\"values\":[\"magic-wands\"],\"negate\":false}]}"

unitAggregationType
enum<string>

The method by which multiple unit event values are aggregated

Available options:
average,
sum,
count_distinct
Example:

"average"

analysisType
enum<string>

The method for analyzing metric events

Available options:
mean,
percentile
Example:

"mean"

percentileValue
integer

The percentile for the analysis method. An integer denoting the target percentile between 0 and 100. Required when analysisType is percentile.

Example:

95

eventDefault
object
lastSeen
integer<int64>

Timestamp of most recent data for this metric, at one-hour fidelity

archived
boolean

Whether the metric version is archived

archivedAt
integer<int64>

Timestamp when the metric version was archived

Example:

"1609459200000"

selector
string

For click metrics, the CSS selectors

urls
object[]

For click and pageview metrics, the target URLs

Example:

"[{\"kind\":\"exact\",\"url\":\"https://www.example.com/page1\"}]"

windowStartOffset
integer<int64>

Not yet implemented - The start of the measurement window, in milliseconds relative to the unit's first exposure to a flag variation

windowEndOffset
integer<int64>

Not yet implemented - The end of the measurement window, in milliseconds relative to the unit's first exposure to a flag variation

winsorLowerPercentile
number

Lower winsorization percentile, expressed as a percent in the open interval (0, 100). When both bounds are set, defines a two-sided clamp range. Otherwise lower-only winsorization.

Example:

1

winsorUpperPercentile
number

Upper winsorization percentile, expressed as a percent in the open interval (0, 100). When both bounds are set, must be greater than winsorLowerPercentile.

Example:

99.5

winsorIncludeImputed
boolean

When true, the percentile bound calculation includes imputed zeros. Only meaningful when at least one bound is set and the metric includes units that didn't send events.

Example:

false

traceQuery
string

For trace metrics, the trace query to use for the metric.

Example:

"service.name = \"checkout\""

traceValueLocation
string

For trace metrics, the location in the trace to use for numeric values.

Example:

"duration"

unitAggregationField
string

For count_distinct metrics, the column to count distinct values of

denominator
object

For ratio metrics, the denominator event configuration

experiments
object[]

Experiments that use this metric, including those using a metric group that contains this metric

metricGroups
object[]

Metric groups that use this metric

lastUsedInExperiment
object

The most recent experiment that used this metric

lastUsedInGuardedRollout
object

The most recent guarded rollout that used this metric

isActive
boolean

Whether the metric is active

Example:

true

_attachedFeatures
object[]

Details on the flags attached to this metric