For the complete documentation index, see llms.txt. For the full documentation snapshot, see llms-full.txt.
Create a new metric in the specified project. The expected POST body differs depending on the specified kind property.
curl --request POST \
--url https://app.launchdarkly.com/api/v2/metrics/{projectKey} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"eventKey": "Order placed",
"isNumeric": false,
"key": "metric-key-123abc",
"kind": "custom"
}
'{
"_id": "5902deadbeef667524a01290",
"_versionId": "version-id-123abc",
"key": "metric-key-123abc",
"name": "My metric",
"kind": "custom",
"_links": {
"parent": {
"href": "/api/v2/metrics/my-project",
"type": "application/json"
},
"self": {
"href": "/api/v2/metrics/my-project/my-metric",
"type": "application/json"
}
},
"tags": [],
"_creationDate": "1628192791148",
"dataSource": {
"key": "<string>",
"environmentKey": "<string>",
"_name": "<string>",
"_integrationKey": "<string>"
},
"experimentCount": 0,
"metricGroupCount": 0,
"activeExperimentCount": 2,
"activeGuardedRolloutCount": 1,
"_version": 1,
"_attachedFlagCount": 0,
"_site": "{\"href\":\"/experiments/metrics/my-metric/edit\",\"type\":\"text/html\"}",
"_access": {
"denied": [
{
"action": "<string>",
"reason": {
"effect": "allow",
"resources": [
"proj/*:env/*;qa_*:/flag/*"
],
"notResources": [
"<string>"
],
"actions": [
"*"
],
"notActions": [
"<string>"
],
"role_name": "<string>"
}
}
],
"allowed": [
{
"action": "<string>",
"reason": {
"effect": "allow",
"resources": [
"proj/*:env/*;qa_*:/flag/*"
],
"notResources": [
"<string>"
],
"actions": [
"*"
],
"notActions": [
"<string>"
],
"role_name": "<string>"
}
}
]
},
"lastModified": {
"date": "2021-08-05T19:46:31.148082Z"
},
"maintainerId": "569fdeadbeef1644facecafe",
"_maintainer": "{\"_links\":{\"self\":{\"href\":\"/api/v2/members/569fdeadbeef1644facecafe\",\"type\":\"application/json\"}},\"_id\":\"569fdeadbeef1644facecafe\",\"firstName\":\"Ariel\",\"lastName\":\"Flores\",\"role\":\"owner\",\"email\":\"ariel@acme.com\"}",
"description": "<string>",
"category": "Error monitoring",
"isNumeric": true,
"successCriteria": "HigherThanBaseline",
"unit": "<string>",
"eventKey": "Order placed",
"randomizationUnits": [
"user"
],
"filters": "{\"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": "average",
"analysisType": "mean",
"percentileValue": 95,
"eventDefault": {
"disabled": true,
"value": 0
},
"lastSeen": 123,
"archived": true,
"archivedAt": "1609459200000",
"selector": "<string>",
"urls": "[{\"kind\":\"exact\",\"url\":\"https://www.example.com/page1\"}]",
"windowStartOffset": 123,
"windowEndOffset": 123,
"traceQuery": "service.name = \"checkout\"",
"traceValueLocation": "duration",
"experiments": [
{
"key": "experiment-key-123abc",
"name": "Example experiment",
"environmentId": "1234a56b7c89d012345e678f",
"environmentKey": "production",
"creationDate": "1654104600000",
"_links": {
"parent": {
"href": "/api/v2/projects/my-project/environments/my-environment",
"type": "application/json"
},
"self": {
"href": "/api/v2/projects/my-project/environments/my-environment/experiments/example-experiment",
"type": "application/json"
}
},
"archivedDate": "1654104600000"
}
],
"metricGroups": [
{
"key": "metric-group-key-123abc",
"name": "My metric group",
"kind": "funnel",
"_links": {
"parent": {
"href": "/api/v2/projects/my-project",
"type": "application/json"
},
"self": {
"href": "/api/v2/projects/my-project/metric-groups/my-metric-group",
"type": "application/json"
}
}
}
],
"lastUsedInExperiment": {
"key": "experiment-key-123abc",
"name": "Example experiment",
"environmentId": "1234a56b7c89d012345e678f",
"environmentKey": "production",
"creationDate": "1654104600000",
"_links": {
"parent": {
"href": "/api/v2/projects/my-project/environments/my-environment",
"type": "application/json"
},
"self": {
"href": "/api/v2/projects/my-project/environments/my-environment/experiments/example-experiment",
"type": "application/json"
}
},
"archivedDate": "1654104600000"
},
"lastUsedInGuardedRollout": {
"_id": "885ccadf-181b-4a9a-8414-7ad6f7ba2db0",
"flagKey": "my-flag",
"flagName": "My Flag",
"environmentKey": "production",
"environmentName": "Production",
"status": "monitoring",
"creationDate": "1654104600000",
"_links": {
"self": {
"href": "/api/v2/projects/my-project/flags/my-flag/environments/production/measured-rollouts/885ccadf-181b-4a9a-8414-7ad6f7ba2db0",
"type": "application/json"
}
},
"flagPurpose": "migration"
},
"isActive": true,
"_attachedFeatures": [
{
"name": "Example flag",
"key": "flag-key-123abc",
"_links": {},
"_site": {
"href": "<string>",
"type": "<string>"
}
}
]
}Documentation Index
Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
The project key
A unique key to reference the metric
"metric-key-123abc"
The kind of event your metric will track
pageview, click, custom, trace "custom"
A human-friendly name for the metric
"Example metric"
Description of the metric
"optional description"
One or more CSS selectors. Required for click metrics only.
".dropdown-toggle"
One or more target URLs. Required for click and pageview metrics only.
Show child attributes
"invalid example"
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.
false
The unit of measure. Applicable for numeric custom and trace metrics only.
"orders"
The event key to use in your code. Required for custom conversion/binary and custom numeric metrics only.
"Order placed"
Success criteria. Required for custom and trace numeric metrics, optional for custom and trace conversion metrics.
HigherThanBaseline, LowerThanBaseline "HigherThanBaseline"
Tags for the metric
["example-tag"]An array of randomization units allowed for this metric
["user"]The ID of the member who maintains this metric
"569fdeadbeef1644facecafe"
The method by which multiple unit event values are aggregated
average, sum "average"
The method for analyzing metric events
"mean"
The percentile for the analysis method. An integer denoting the target percentile between 0 and 100. Required when analysisType is percentile.
95
Show child attributes
Show child attributes
Filters for the metric to exclude certain events from being included. This is only supported for custom metrics.
Show child attributes
Not yet implemented - The start of the measurement window, in milliseconds relative to the unit's first exposure to a flag variation
Not yet implemented - The end of the measurement window, in milliseconds relative to the unit's first exposure to a flag variation
The trace query to use for the metric. Required for trace metrics.
"service.name = \"checkout\""
The location in the trace to use for numeric values. Required for numeric trace metrics.
"duration"
Metric response
The ID of this metric
"5902deadbeef667524a01290"
The version ID of the metric
"version-id-123abc"
A unique key to reference the metric
"metric-key-123abc"
A human-friendly name for the metric
"My metric"
The kind of event the metric tracks
pageview, click, custom, trace "custom"
The location and content type of related resources
Show child attributes
{
"parent": {
"href": "/api/v2/metrics/my-project",
"type": "application/json"
},
"self": {
"href": "/api/v2/metrics/my-project/my-metric",
"type": "application/json"
}
}Tags for the metric
[]Timestamp of when the metric was created
"1628192791148"
Show child attributes
The number of experiments using this metric
0
The number of metric groups using this metric
0
The number of active experiments using this metric
2
The number of active guarded rollouts using this metric
1
Version of the metric
1
The number of feature flags currently attached to this metric
0
Details on how to access the metric in the LaunchDarkly UI
Show child attributes
"{\"href\":\"/experiments/metrics/my-metric/edit\",\"type\":\"text/html\"}"
Details on the allowed and denied actions for this metric
Show child attributes
Show child attributes
The ID of the member who maintains this metric
"569fdeadbeef1644facecafe"
Details on the member who maintains this metric
Show child attributes
"{\"_links\":{\"self\":{\"href\":\"/api/v2/members/569fdeadbeef1644facecafe\",\"type\":\"application/json\"}},\"_id\":\"569fdeadbeef1644facecafe\",\"firstName\":\"Ariel\",\"lastName\":\"Flores\",\"role\":\"owner\",\"email\":\"ariel@acme.com\"}"
Description of the metric
The category of the metric
"Error monitoring"
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).
true
For custom and trace metrics, the success criteria
HigherThanBaseline, LowerThanBaseline For numeric custom and trace metrics, the unit of measure
For custom metrics, the event key to use in your code
"Order placed"
An array of randomization units allowed for this metric
["user"]The filters narrowing down the audience based on context attributes or event properties.
Show child attributes
"{\"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}]}"
The method by which multiple unit event values are aggregated
average, sum "average"
The method for analyzing metric events
mean, percentile "mean"
The percentile for the analysis method. An integer denoting the target percentile between 0 and 100. Required when analysisType is percentile.
95
Show child attributes
Timestamp of most recent data for this metric, at one-hour fidelity
Whether the metric version is archived
Timestamp when the metric version was archived
"1609459200000"
For click metrics, the CSS selectors
For click and pageview metrics, the target URLs
Show child attributes
"[{\"kind\":\"exact\",\"url\":\"https://www.example.com/page1\"}]"
Not yet implemented - The start of the measurement window, in milliseconds relative to the unit's first exposure to a flag variation
Not yet implemented - The end of the measurement window, in milliseconds relative to the unit's first exposure to a flag variation
For trace metrics, the trace query to use for the metric.
"service.name = \"checkout\""
For trace metrics, the location in the trace to use for numeric values.
"duration"
Experiments that use this metric, including those using a metric group that contains this metric
Show child attributes
Metric groups that use this metric
Show child attributes
The most recent experiment that used this metric
Show child attributes
The most recent guarded rollout that used this metric
Show child attributes
Whether the metric is active
true
Details on the flags attached to this metric
Show child attributes
curl --request POST \
--url https://app.launchdarkly.com/api/v2/metrics/{projectKey} \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"eventKey": "Order placed",
"isNumeric": false,
"key": "metric-key-123abc",
"kind": "custom"
}
'{
"_id": "5902deadbeef667524a01290",
"_versionId": "version-id-123abc",
"key": "metric-key-123abc",
"name": "My metric",
"kind": "custom",
"_links": {
"parent": {
"href": "/api/v2/metrics/my-project",
"type": "application/json"
},
"self": {
"href": "/api/v2/metrics/my-project/my-metric",
"type": "application/json"
}
},
"tags": [],
"_creationDate": "1628192791148",
"dataSource": {
"key": "<string>",
"environmentKey": "<string>",
"_name": "<string>",
"_integrationKey": "<string>"
},
"experimentCount": 0,
"metricGroupCount": 0,
"activeExperimentCount": 2,
"activeGuardedRolloutCount": 1,
"_version": 1,
"_attachedFlagCount": 0,
"_site": "{\"href\":\"/experiments/metrics/my-metric/edit\",\"type\":\"text/html\"}",
"_access": {
"denied": [
{
"action": "<string>",
"reason": {
"effect": "allow",
"resources": [
"proj/*:env/*;qa_*:/flag/*"
],
"notResources": [
"<string>"
],
"actions": [
"*"
],
"notActions": [
"<string>"
],
"role_name": "<string>"
}
}
],
"allowed": [
{
"action": "<string>",
"reason": {
"effect": "allow",
"resources": [
"proj/*:env/*;qa_*:/flag/*"
],
"notResources": [
"<string>"
],
"actions": [
"*"
],
"notActions": [
"<string>"
],
"role_name": "<string>"
}
}
]
},
"lastModified": {
"date": "2021-08-05T19:46:31.148082Z"
},
"maintainerId": "569fdeadbeef1644facecafe",
"_maintainer": "{\"_links\":{\"self\":{\"href\":\"/api/v2/members/569fdeadbeef1644facecafe\",\"type\":\"application/json\"}},\"_id\":\"569fdeadbeef1644facecafe\",\"firstName\":\"Ariel\",\"lastName\":\"Flores\",\"role\":\"owner\",\"email\":\"ariel@acme.com\"}",
"description": "<string>",
"category": "Error monitoring",
"isNumeric": true,
"successCriteria": "HigherThanBaseline",
"unit": "<string>",
"eventKey": "Order placed",
"randomizationUnits": [
"user"
],
"filters": "{\"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": "average",
"analysisType": "mean",
"percentileValue": 95,
"eventDefault": {
"disabled": true,
"value": 0
},
"lastSeen": 123,
"archived": true,
"archivedAt": "1609459200000",
"selector": "<string>",
"urls": "[{\"kind\":\"exact\",\"url\":\"https://www.example.com/page1\"}]",
"windowStartOffset": 123,
"windowEndOffset": 123,
"traceQuery": "service.name = \"checkout\"",
"traceValueLocation": "duration",
"experiments": [
{
"key": "experiment-key-123abc",
"name": "Example experiment",
"environmentId": "1234a56b7c89d012345e678f",
"environmentKey": "production",
"creationDate": "1654104600000",
"_links": {
"parent": {
"href": "/api/v2/projects/my-project/environments/my-environment",
"type": "application/json"
},
"self": {
"href": "/api/v2/projects/my-project/environments/my-environment/experiments/example-experiment",
"type": "application/json"
}
},
"archivedDate": "1654104600000"
}
],
"metricGroups": [
{
"key": "metric-group-key-123abc",
"name": "My metric group",
"kind": "funnel",
"_links": {
"parent": {
"href": "/api/v2/projects/my-project",
"type": "application/json"
},
"self": {
"href": "/api/v2/projects/my-project/metric-groups/my-metric-group",
"type": "application/json"
}
}
}
],
"lastUsedInExperiment": {
"key": "experiment-key-123abc",
"name": "Example experiment",
"environmentId": "1234a56b7c89d012345e678f",
"environmentKey": "production",
"creationDate": "1654104600000",
"_links": {
"parent": {
"href": "/api/v2/projects/my-project/environments/my-environment",
"type": "application/json"
},
"self": {
"href": "/api/v2/projects/my-project/environments/my-environment/experiments/example-experiment",
"type": "application/json"
}
},
"archivedDate": "1654104600000"
},
"lastUsedInGuardedRollout": {
"_id": "885ccadf-181b-4a9a-8414-7ad6f7ba2db0",
"flagKey": "my-flag",
"flagName": "My Flag",
"environmentKey": "production",
"environmentName": "Production",
"status": "monitoring",
"creationDate": "1654104600000",
"_links": {
"self": {
"href": "/api/v2/projects/my-project/flags/my-flag/environments/production/measured-rollouts/885ccadf-181b-4a9a-8414-7ad6f7ba2db0",
"type": "application/json"
}
},
"flagPurpose": "migration"
},
"isActive": true,
"_attachedFeatures": [
{
"name": "Example flag",
"key": "flag-key-123abc",
"_links": {},
"_site": {
"href": "<string>",
"type": "<string>"
}
}
]
}