Create metric group
For the complete documentation index, see llms.txt. For the full documentation snapshot, see llms-full.txt.
Create a new metric group in the specified project
curl --request POST \
--url https://app.launchdarkly.com/api/v2/projects/{projectKey}/metric-groups \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "My metric group",
"kind": "funnel",
"maintainerId": "569fdeadbeef1644facecafe",
"tags": [
"ops"
],
"metrics": [
{
"key": "metric-key-123abc",
"nameInGroup": "Step 1"
}
],
"key": "metric-group-key-123abc",
"description": "Description of the metric group"
}
'import requests
url = "https://app.launchdarkly.com/api/v2/projects/{projectKey}/metric-groups"
payload = {
"name": "My metric group",
"kind": "funnel",
"maintainerId": "569fdeadbeef1644facecafe",
"tags": ["ops"],
"metrics": [
{
"key": "metric-key-123abc",
"nameInGroup": "Step 1"
}
],
"key": "metric-group-key-123abc",
"description": "Description of the metric group"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'My metric group',
kind: 'funnel',
maintainerId: '569fdeadbeef1644facecafe',
tags: ['ops'],
metrics: [{key: 'metric-key-123abc', nameInGroup: 'Step 1'}],
key: 'metric-group-key-123abc',
description: 'Description of the metric group'
})
};
fetch('https://app.launchdarkly.com/api/v2/projects/{projectKey}/metric-groups', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.launchdarkly.com/api/v2/projects/{projectKey}/metric-groups",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'My metric group',
'kind' => 'funnel',
'maintainerId' => '569fdeadbeef1644facecafe',
'tags' => [
'ops'
],
'metrics' => [
[
'key' => 'metric-key-123abc',
'nameInGroup' => 'Step 1'
]
],
'key' => 'metric-group-key-123abc',
'description' => 'Description of the metric group'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.launchdarkly.com/api/v2/projects/{projectKey}/metric-groups"
payload := strings.NewReader("{\n \"name\": \"My metric group\",\n \"kind\": \"funnel\",\n \"maintainerId\": \"569fdeadbeef1644facecafe\",\n \"tags\": [\n \"ops\"\n ],\n \"metrics\": [\n {\n \"key\": \"metric-key-123abc\",\n \"nameInGroup\": \"Step 1\"\n }\n ],\n \"key\": \"metric-group-key-123abc\",\n \"description\": \"Description of the metric group\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.launchdarkly.com/api/v2/projects/{projectKey}/metric-groups")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"My metric group\",\n \"kind\": \"funnel\",\n \"maintainerId\": \"569fdeadbeef1644facecafe\",\n \"tags\": [\n \"ops\"\n ],\n \"metrics\": [\n {\n \"key\": \"metric-key-123abc\",\n \"nameInGroup\": \"Step 1\"\n }\n ],\n \"key\": \"metric-group-key-123abc\",\n \"description\": \"Description of the metric group\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.launchdarkly.com/api/v2/projects/{projectKey}/metric-groups")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"My metric group\",\n \"kind\": \"funnel\",\n \"maintainerId\": \"569fdeadbeef1644facecafe\",\n \"tags\": [\n \"ops\"\n ],\n \"metrics\": [\n {\n \"key\": \"metric-key-123abc\",\n \"nameInGroup\": \"Step 1\"\n }\n ],\n \"key\": \"metric-group-key-123abc\",\n \"description\": \"Description of the metric group\"\n}"
response = http.request(request)
puts response.read_body{
"_id": "bc3e5be1-02d2-40c7-9926-26d0aacd7aab",
"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"
}
},
"tags": [
"ops"
],
"_creationDate": "1628192791148",
"_lastModified": "1628192791148",
"maintainer": {
"member": {
"_links": {
"self": {
"href": "/api/v2/members/569f183514f4432160000007",
"type": "application/json"
}
},
"_id": "569f183514f4432160000007",
"role": "admin",
"email": "ariel@acme.com",
"firstName": "Ariel",
"lastName": "Flores"
},
"team": {
"customRoleKeys": [
"access-to-test-projects"
],
"key": "team-key-123abc",
"name": "QA Team",
"_links": {}
}
},
"metrics": [
{
"key": "metric-key-123abc",
"name": "Example metric",
"kind": "custom",
"_links": {
"self": {
"href": "/api/v2/metrics/my-project/my-metric",
"type": "application/json"
}
},
"_versionId": "version-id-123abc",
"isNumeric": true,
"unitAggregationType": "sum",
"eventKey": "event-key-123abc",
"nameInGroup": "Step 1",
"randomizationUnits": [
"user"
]
}
],
"_version": 1,
"description": "Description of the metric group",
"_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>"
}
}
]
},
"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"
}
],
"experimentCount": 0,
"activeExperimentCount": 0,
"activeGuardedRolloutCount": 0
}{
"code": "invalid_request",
"message": "Invalid request body"
}{
"code": "unauthorized",
"message": "Invalid access token"
}{
"code": "forbidden",
"message": "Forbidden. Access to the requested resource was denied."
}{
"code": "not_found",
"message": "Invalid resource identifier"
}{
"code": "method_not_allowed",
"message": "Method not allowed"
}{
"code": "rate_limited",
"message": "You've exceeded the API rate limit. Try again later."
}Authorizations
Path Parameters
The project key
Body
A human-friendly name for the metric group
"My metric group"
The type of the metric group
funnel, standard "funnel"
The ID of the member who maintains this metric group
"569fdeadbeef1644facecafe"
Tags for the metric group
["ops"]
An ordered list of the metrics in this metric group
Show child attributes
Show child attributes
A unique key to reference the metric group
"metric-group-key-123abc"
Description of the metric group
"Description of the metric group"
Response
Metric group response
The ID of this metric group
"bc3e5be1-02d2-40c7-9926-26d0aacd7aab"
A unique key to reference the metric group
"metric-group-key-123abc"
A human-friendly name for the metric group
"My metric group"
The type of the metric group
funnel, standard "funnel"
The location and content type of related resources
Show child attributes
Show child attributes
{
"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"
}
}
Tags for the metric group
["ops"]
Timestamp of when the metric group was created
"1628192791148"
Timestamp of when the metric group was last modified
"1628192791148"
The maintainer of this metric
Show child attributes
Show child attributes
An ordered list of the metrics in this metric group
Show child attributes
Show child attributes
The version of this metric group
1
Description of the metric group
"Description of the metric group"
Details on the allowed and denied actions for this metric group
Show child attributes
Show child attributes
Experiments that use this metric group. Only included if specified in the expand query parameter in a getMetricGroup request.
Show child attributes
Show child attributes
The number of experiments using this metric group
0
The number of active experiments using this metric group
0
The number of active guarded rollouts using this metric group
0
curl --request POST \
--url https://app.launchdarkly.com/api/v2/projects/{projectKey}/metric-groups \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "My metric group",
"kind": "funnel",
"maintainerId": "569fdeadbeef1644facecafe",
"tags": [
"ops"
],
"metrics": [
{
"key": "metric-key-123abc",
"nameInGroup": "Step 1"
}
],
"key": "metric-group-key-123abc",
"description": "Description of the metric group"
}
'import requests
url = "https://app.launchdarkly.com/api/v2/projects/{projectKey}/metric-groups"
payload = {
"name": "My metric group",
"kind": "funnel",
"maintainerId": "569fdeadbeef1644facecafe",
"tags": ["ops"],
"metrics": [
{
"key": "metric-key-123abc",
"nameInGroup": "Step 1"
}
],
"key": "metric-group-key-123abc",
"description": "Description of the metric group"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'My metric group',
kind: 'funnel',
maintainerId: '569fdeadbeef1644facecafe',
tags: ['ops'],
metrics: [{key: 'metric-key-123abc', nameInGroup: 'Step 1'}],
key: 'metric-group-key-123abc',
description: 'Description of the metric group'
})
};
fetch('https://app.launchdarkly.com/api/v2/projects/{projectKey}/metric-groups', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.launchdarkly.com/api/v2/projects/{projectKey}/metric-groups",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'My metric group',
'kind' => 'funnel',
'maintainerId' => '569fdeadbeef1644facecafe',
'tags' => [
'ops'
],
'metrics' => [
[
'key' => 'metric-key-123abc',
'nameInGroup' => 'Step 1'
]
],
'key' => 'metric-group-key-123abc',
'description' => 'Description of the metric group'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.launchdarkly.com/api/v2/projects/{projectKey}/metric-groups"
payload := strings.NewReader("{\n \"name\": \"My metric group\",\n \"kind\": \"funnel\",\n \"maintainerId\": \"569fdeadbeef1644facecafe\",\n \"tags\": [\n \"ops\"\n ],\n \"metrics\": [\n {\n \"key\": \"metric-key-123abc\",\n \"nameInGroup\": \"Step 1\"\n }\n ],\n \"key\": \"metric-group-key-123abc\",\n \"description\": \"Description of the metric group\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.launchdarkly.com/api/v2/projects/{projectKey}/metric-groups")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"My metric group\",\n \"kind\": \"funnel\",\n \"maintainerId\": \"569fdeadbeef1644facecafe\",\n \"tags\": [\n \"ops\"\n ],\n \"metrics\": [\n {\n \"key\": \"metric-key-123abc\",\n \"nameInGroup\": \"Step 1\"\n }\n ],\n \"key\": \"metric-group-key-123abc\",\n \"description\": \"Description of the metric group\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.launchdarkly.com/api/v2/projects/{projectKey}/metric-groups")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"My metric group\",\n \"kind\": \"funnel\",\n \"maintainerId\": \"569fdeadbeef1644facecafe\",\n \"tags\": [\n \"ops\"\n ],\n \"metrics\": [\n {\n \"key\": \"metric-key-123abc\",\n \"nameInGroup\": \"Step 1\"\n }\n ],\n \"key\": \"metric-group-key-123abc\",\n \"description\": \"Description of the metric group\"\n}"
response = http.request(request)
puts response.read_body{
"_id": "bc3e5be1-02d2-40c7-9926-26d0aacd7aab",
"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"
}
},
"tags": [
"ops"
],
"_creationDate": "1628192791148",
"_lastModified": "1628192791148",
"maintainer": {
"member": {
"_links": {
"self": {
"href": "/api/v2/members/569f183514f4432160000007",
"type": "application/json"
}
},
"_id": "569f183514f4432160000007",
"role": "admin",
"email": "ariel@acme.com",
"firstName": "Ariel",
"lastName": "Flores"
},
"team": {
"customRoleKeys": [
"access-to-test-projects"
],
"key": "team-key-123abc",
"name": "QA Team",
"_links": {}
}
},
"metrics": [
{
"key": "metric-key-123abc",
"name": "Example metric",
"kind": "custom",
"_links": {
"self": {
"href": "/api/v2/metrics/my-project/my-metric",
"type": "application/json"
}
},
"_versionId": "version-id-123abc",
"isNumeric": true,
"unitAggregationType": "sum",
"eventKey": "event-key-123abc",
"nameInGroup": "Step 1",
"randomizationUnits": [
"user"
]
}
],
"_version": 1,
"description": "Description of the metric group",
"_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>"
}
}
]
},
"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"
}
],
"experimentCount": 0,
"activeExperimentCount": 0,
"activeGuardedRolloutCount": 0
}{
"code": "invalid_request",
"message": "Invalid request body"
}{
"code": "unauthorized",
"message": "Invalid access token"
}{
"code": "forbidden",
"message": "Forbidden. Access to the requested resource was denied."
}{
"code": "not_found",
"message": "Invalid resource identifier"
}{
"code": "method_not_allowed",
"message": "Method not allowed"
}{
"code": "rate_limited",
"message": "You've exceeded the API rate limit. Try again later."
}