Create metric

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

Authentication

Authorizationstring
API Key authentication via header

Path parameters

projectKeystringRequiredformat: "string"
The project key

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
dataSourceobjectOptional
filtersobjectOptional
Filters for the metric to exclude certain events from being included. This is only supported for custom metrics.

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
dataSourceobject
experimentCountinteger
The number of experiments using this metric
metricGroupCountinteger
The number of metric groups using this metric
activeExperimentCountinteger
The number of active experiments using this metric
activeGuardedRolloutCountinteger
The number of active guarded rollouts using this metric
_versioninteger
Version of the metric
_attachedFlagCountinteger
The number of feature flags currently attached to this metric
_siteobject
Details on how to access the metric in the LaunchDarkly UI
_accessobject
Details on the allowed and denied actions for this metric
lastModifiedobject
maintainerIdstring
The ID of the member who maintains this metric
_maintainerobject
Details on the member who maintains this metric
descriptionstring
Description of the metric
categorystring
The category of the metric
isNumericboolean

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

successCriteriaenum
For custom metrics, the success criteria
Allowed values:
unitstring
For numeric custom metrics, the unit of measure
eventKeystring
For custom metrics, the event key to use in your code
randomizationUnitslist of strings
An array of randomization units allowed for this metric
filtersobject
The filters narrowing down the audience based on context attributes or event properties.
unitAggregationTypeenum
The method by which multiple unit event values are aggregated
Allowed values:
analysisTypeenum
The method for analyzing metric events
Allowed values:
percentileValueinteger

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

eventDefaultobject
lastSeenlong

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

archivedboolean
Whether the metric version is archived
archivedAtlong
Timestamp when the metric version was archived
selectorstring
For click metrics, the CSS selectors
urlslist of maps from strings to any
For click and pageview metrics, the target URLs
experimentslist of objects
Experiments that use this metric, including those using a metric group that contains this metric
metricGroupslist of objects
Metric groups that use this metric
lastUsedInExperimentobject
The most recent experiment that used this metric
lastUsedInGuardedRolloutobject
The most recent guarded rollout that used this metric
isActiveboolean
Whether the metric is active
_attachedFeatureslist of objects
Details on the flags attached to this metric

Errors

400
Bad Request Error
401
Unauthorized Error
403
Forbidden Error
404
Not Found Error
409
Conflict Error
429
Too Many Requests Error