Create metric

Create a new metric in the specified project. The expected POST body differs depending on the specified kind property.

Path parameters

projectKeystringRequired
The project key

Headers

AuthorizationstringRequired

Request

This endpoint expects an object.
keystringRequired
A unique key to reference the metric
kindenumRequired
The kind of event your metric will track
Allowed values:
namestringOptional

A human-friendly name for the metric

descriptionstringOptional
Description of the metric
selectorstringOptional
One or more CSS selectors. Required for click metrics only.
urlslist of objectsOptional
One or more target URLs. Required for click and pageview metrics only.
isNumericbooleanOptional

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 metrics only.

unitstringOptional
The unit of measure. Applicable for numeric custom metrics only.
eventKeystringOptional

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

successCriteriaenumOptional
Success criteria. Required for custom numeric metrics, optional for custom conversion metrics.
Allowed values:
tagslist of stringsOptional
Tags for the metric
randomizationUnitslist of stringsOptional
An array of randomization units allowed for this metric
maintainerIdstringOptional
The ID of the member who maintains this metric
unitAggregationTypeenumOptional
The method by which multiple unit event values are aggregated
Allowed values:
analysisTypestringOptional
The method for analyzing metric events
percentileValueintegerOptional

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

eventDefaultobjectOptional

Response

Metric response
_idstring
The ID of this metric
_versionIdstring
The version ID of the metric
keystring
A unique key to reference the metric
namestring

A human-friendly name for the metric

kindenum
The kind of event the metric tracks
Allowed values:
tagslist of strings
Tags for the metric
_creationDatelong
Timestamp of when the metric was created
experimentCountintegerOptional
The number of experiments using this metric
metricGroupCountintegerOptional
The number of metric groups using this metric
_attachedFlagCountintegerOptional
The number of feature flags currently attached to this metric
_siteobjectOptional
Details on how to access the metric in the LaunchDarkly UI
_accessobjectOptional
Details on the allowed and denied actions for this metric
lastModifiedobjectOptional
maintainerIdstringOptional
The ID of the member who maintains this metric
_maintainerobjectOptional
Details on the member who maintains this metric
descriptionstringOptional
Description of the metric
categorystringOptional
The category of the metric
isNumericbooleanOptional

For custom 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).

successCriteriaenumOptional
For custom metrics, the success criteria
Allowed values:
unitstringOptional
For numeric custom metrics, the unit of measure
eventKeystringOptional
For custom metrics, the event key to use in your code
randomizationUnitslist of stringsOptional
An array of randomization units allowed for this metric
filtersobjectOptional
The filters narrowing down the audience based on context attributes or event properties.
unitAggregationTypeenumOptional
The method by which multiple unit event values are aggregated
Allowed values:
analysisTypeenumOptional
The method for analyzing metric events
Allowed values:
percentileValueintegerOptional

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

eventDefaultobjectOptional
experimentslist of objectsOptional
Experiments that use this metric, including those using a metric group that contains this metric
metricGroupslist of objectsOptional
Metric groups that use this metric
isActivebooleanOptional
Whether the metric is active
_attachedFeatureslist of objectsOptional
Details on the flags attached to this metric
_versionintegerOptional
Version of the metric
selectorstringOptional
For click metrics, the CSS selectors
urlslist of maps from strings to anyOptional
For click and pageview metrics, the target URLs

Errors