curl --request POST \
--url https://statsigapi.net/console/v1/metrics \
--header 'Content-Type: application/json' \
--header 'STATSIG-API-KEY: <api-key>' \
--data '
{
"name": "metricName",
"type": "sum",
"isVerified": false,
"isReadOnly": false,
"unitTypes": [
"stableID",
"userID"
],
"metricEvents": [
{
"name": "event1",
"type": "value"
}
],
"metricComponentMetrics": [],
"description": "<string>",
"directionality": "increase",
"tags": [
"tag1",
"tag2"
],
"isPermanent": false,
"rollupTimeWindow": "custom",
"customRollUpStart": 1,
"customRollUpEnd": 1,
"funnelEventList": [
{
"name": "event1",
"type": "event_dau"
}
],
"warehouseNative": {
"metricSourceName": "<string>",
"criteria": [
{
"column": "<string>",
"values": [
"<string>"
],
"nullVacuousOverride": true
}
],
"waitForCohortWindow": true,
"denominatorCriteria": [
{
"column": "<string>",
"values": [
"<string>"
],
"nullVacuousOverride": true
}
],
"denominatorCustomRollupEnd": 123,
"denominatorCustomRollupStart": 123,
"denominatorMetricSourceName": "<string>",
"denominatorRollupTimeWindow": "<string>",
"denominatorValueColumn": "<string>",
"funnelCalculationWindow": 123,
"funnelEvents": [
{
"criteria": [
{
"column": "<string>",
"values": [
"<string>"
],
"nullVacuousOverride": true
}
],
"metricSourceName": "<string>",
"name": "<string>",
"sessionIdentifierField": "<string>"
}
],
"metricDimensionColumns": [
"<string>"
],
"metricBakeDays": 123,
"valueColumn": "<string>",
"winsorizationHigh": 0.5,
"winsorizationLow": 0.5,
"cupedAttributionWindow": 123,
"onlyIncludeUsersWithConversionEvent": true,
"percentile": 123,
"valueThreshold": 123,
"cap": 123,
"rollupTimeWindow": "<string>",
"customRollUpStart": 123,
"customRollUpEnd": 123,
"allowNullRatioDenominator": true
},
"team": "<string>",
"teamID": "<string>",
"dryRun": true
}
'import requests
url = "https://statsigapi.net/console/v1/metrics"
payload = {
"name": "metricName",
"type": "sum",
"isVerified": False,
"isReadOnly": False,
"unitTypes": ["stableID", "userID"],
"metricEvents": [
{
"name": "event1",
"type": "value"
}
],
"metricComponentMetrics": [],
"description": "<string>",
"directionality": "increase",
"tags": ["tag1", "tag2"],
"isPermanent": False,
"rollupTimeWindow": "custom",
"customRollUpStart": 1,
"customRollUpEnd": 1,
"funnelEventList": [
{
"name": "event1",
"type": "event_dau"
}
],
"warehouseNative": {
"metricSourceName": "<string>",
"criteria": [
{
"column": "<string>",
"values": ["<string>"],
"nullVacuousOverride": True
}
],
"waitForCohortWindow": True,
"denominatorCriteria": [
{
"column": "<string>",
"values": ["<string>"],
"nullVacuousOverride": True
}
],
"denominatorCustomRollupEnd": 123,
"denominatorCustomRollupStart": 123,
"denominatorMetricSourceName": "<string>",
"denominatorRollupTimeWindow": "<string>",
"denominatorValueColumn": "<string>",
"funnelCalculationWindow": 123,
"funnelEvents": [
{
"criteria": [
{
"column": "<string>",
"values": ["<string>"],
"nullVacuousOverride": True
}
],
"metricSourceName": "<string>",
"name": "<string>",
"sessionIdentifierField": "<string>"
}
],
"metricDimensionColumns": ["<string>"],
"metricBakeDays": 123,
"valueColumn": "<string>",
"winsorizationHigh": 0.5,
"winsorizationLow": 0.5,
"cupedAttributionWindow": 123,
"onlyIncludeUsersWithConversionEvent": True,
"percentile": 123,
"valueThreshold": 123,
"cap": 123,
"rollupTimeWindow": "<string>",
"customRollUpStart": 123,
"customRollUpEnd": 123,
"allowNullRatioDenominator": True
},
"team": "<string>",
"teamID": "<string>",
"dryRun": True
}
headers = {
"STATSIG-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'STATSIG-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'metricName',
type: 'sum',
isVerified: false,
isReadOnly: false,
unitTypes: ['stableID', 'userID'],
metricEvents: [{name: 'event1', type: 'value'}],
metricComponentMetrics: [],
description: '<string>',
directionality: 'increase',
tags: ['tag1', 'tag2'],
isPermanent: false,
rollupTimeWindow: 'custom',
customRollUpStart: 1,
customRollUpEnd: 1,
funnelEventList: [{name: 'event1', type: 'event_dau'}],
warehouseNative: {
metricSourceName: '<string>',
criteria: [{column: '<string>', values: ['<string>'], nullVacuousOverride: true}],
waitForCohortWindow: true,
denominatorCriteria: [{column: '<string>', values: ['<string>'], nullVacuousOverride: true}],
denominatorCustomRollupEnd: 123,
denominatorCustomRollupStart: 123,
denominatorMetricSourceName: '<string>',
denominatorRollupTimeWindow: '<string>',
denominatorValueColumn: '<string>',
funnelCalculationWindow: 123,
funnelEvents: [
{
criteria: [{column: '<string>', values: ['<string>'], nullVacuousOverride: true}],
metricSourceName: '<string>',
name: '<string>',
sessionIdentifierField: '<string>'
}
],
metricDimensionColumns: ['<string>'],
metricBakeDays: 123,
valueColumn: '<string>',
winsorizationHigh: 0.5,
winsorizationLow: 0.5,
cupedAttributionWindow: 123,
onlyIncludeUsersWithConversionEvent: true,
percentile: 123,
valueThreshold: 123,
cap: 123,
rollupTimeWindow: '<string>',
customRollUpStart: 123,
customRollUpEnd: 123,
allowNullRatioDenominator: true
},
team: '<string>',
teamID: '<string>',
dryRun: true
})
};
fetch('https://statsigapi.net/console/v1/metrics', 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://statsigapi.net/console/v1/metrics",
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' => 'metricName',
'type' => 'sum',
'isVerified' => false,
'isReadOnly' => false,
'unitTypes' => [
'stableID',
'userID'
],
'metricEvents' => [
[
'name' => 'event1',
'type' => 'value'
]
],
'metricComponentMetrics' => [
],
'description' => '<string>',
'directionality' => 'increase',
'tags' => [
'tag1',
'tag2'
],
'isPermanent' => false,
'rollupTimeWindow' => 'custom',
'customRollUpStart' => 1,
'customRollUpEnd' => 1,
'funnelEventList' => [
[
'name' => 'event1',
'type' => 'event_dau'
]
],
'warehouseNative' => [
'metricSourceName' => '<string>',
'criteria' => [
[
'column' => '<string>',
'values' => [
'<string>'
],
'nullVacuousOverride' => true
]
],
'waitForCohortWindow' => true,
'denominatorCriteria' => [
[
'column' => '<string>',
'values' => [
'<string>'
],
'nullVacuousOverride' => true
]
],
'denominatorCustomRollupEnd' => 123,
'denominatorCustomRollupStart' => 123,
'denominatorMetricSourceName' => '<string>',
'denominatorRollupTimeWindow' => '<string>',
'denominatorValueColumn' => '<string>',
'funnelCalculationWindow' => 123,
'funnelEvents' => [
[
'criteria' => [
[
'column' => '<string>',
'values' => [
'<string>'
],
'nullVacuousOverride' => true
]
],
'metricSourceName' => '<string>',
'name' => '<string>',
'sessionIdentifierField' => '<string>'
]
],
'metricDimensionColumns' => [
'<string>'
],
'metricBakeDays' => 123,
'valueColumn' => '<string>',
'winsorizationHigh' => 0.5,
'winsorizationLow' => 0.5,
'cupedAttributionWindow' => 123,
'onlyIncludeUsersWithConversionEvent' => true,
'percentile' => 123,
'valueThreshold' => 123,
'cap' => 123,
'rollupTimeWindow' => '<string>',
'customRollUpStart' => 123,
'customRollUpEnd' => 123,
'allowNullRatioDenominator' => true
],
'team' => '<string>',
'teamID' => '<string>',
'dryRun' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"STATSIG-API-KEY: <api-key>"
],
]);
$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://statsigapi.net/console/v1/metrics"
payload := strings.NewReader("{\n \"name\": \"metricName\",\n \"type\": \"sum\",\n \"isVerified\": false,\n \"isReadOnly\": false,\n \"unitTypes\": [\n \"stableID\",\n \"userID\"\n ],\n \"metricEvents\": [\n {\n \"name\": \"event1\",\n \"type\": \"value\"\n }\n ],\n \"metricComponentMetrics\": [],\n \"description\": \"<string>\",\n \"directionality\": \"increase\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"isPermanent\": false,\n \"rollupTimeWindow\": \"custom\",\n \"customRollUpStart\": 1,\n \"customRollUpEnd\": 1,\n \"funnelEventList\": [\n {\n \"name\": \"event1\",\n \"type\": \"event_dau\"\n }\n ],\n \"warehouseNative\": {\n \"metricSourceName\": \"<string>\",\n \"criteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"waitForCohortWindow\": true,\n \"denominatorCriteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"denominatorCustomRollupEnd\": 123,\n \"denominatorCustomRollupStart\": 123,\n \"denominatorMetricSourceName\": \"<string>\",\n \"denominatorRollupTimeWindow\": \"<string>\",\n \"denominatorValueColumn\": \"<string>\",\n \"funnelCalculationWindow\": 123,\n \"funnelEvents\": [\n {\n \"criteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"metricSourceName\": \"<string>\",\n \"name\": \"<string>\",\n \"sessionIdentifierField\": \"<string>\"\n }\n ],\n \"metricDimensionColumns\": [\n \"<string>\"\n ],\n \"metricBakeDays\": 123,\n \"valueColumn\": \"<string>\",\n \"winsorizationHigh\": 0.5,\n \"winsorizationLow\": 0.5,\n \"cupedAttributionWindow\": 123,\n \"onlyIncludeUsersWithConversionEvent\": true,\n \"percentile\": 123,\n \"valueThreshold\": 123,\n \"cap\": 123,\n \"rollupTimeWindow\": \"<string>\",\n \"customRollUpStart\": 123,\n \"customRollUpEnd\": 123,\n \"allowNullRatioDenominator\": true\n },\n \"team\": \"<string>\",\n \"teamID\": \"<string>\",\n \"dryRun\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("STATSIG-API-KEY", "<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://statsigapi.net/console/v1/metrics")
.header("STATSIG-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"metricName\",\n \"type\": \"sum\",\n \"isVerified\": false,\n \"isReadOnly\": false,\n \"unitTypes\": [\n \"stableID\",\n \"userID\"\n ],\n \"metricEvents\": [\n {\n \"name\": \"event1\",\n \"type\": \"value\"\n }\n ],\n \"metricComponentMetrics\": [],\n \"description\": \"<string>\",\n \"directionality\": \"increase\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"isPermanent\": false,\n \"rollupTimeWindow\": \"custom\",\n \"customRollUpStart\": 1,\n \"customRollUpEnd\": 1,\n \"funnelEventList\": [\n {\n \"name\": \"event1\",\n \"type\": \"event_dau\"\n }\n ],\n \"warehouseNative\": {\n \"metricSourceName\": \"<string>\",\n \"criteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"waitForCohortWindow\": true,\n \"denominatorCriteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"denominatorCustomRollupEnd\": 123,\n \"denominatorCustomRollupStart\": 123,\n \"denominatorMetricSourceName\": \"<string>\",\n \"denominatorRollupTimeWindow\": \"<string>\",\n \"denominatorValueColumn\": \"<string>\",\n \"funnelCalculationWindow\": 123,\n \"funnelEvents\": [\n {\n \"criteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"metricSourceName\": \"<string>\",\n \"name\": \"<string>\",\n \"sessionIdentifierField\": \"<string>\"\n }\n ],\n \"metricDimensionColumns\": [\n \"<string>\"\n ],\n \"metricBakeDays\": 123,\n \"valueColumn\": \"<string>\",\n \"winsorizationHigh\": 0.5,\n \"winsorizationLow\": 0.5,\n \"cupedAttributionWindow\": 123,\n \"onlyIncludeUsersWithConversionEvent\": true,\n \"percentile\": 123,\n \"valueThreshold\": 123,\n \"cap\": 123,\n \"rollupTimeWindow\": \"<string>\",\n \"customRollUpStart\": 123,\n \"customRollUpEnd\": 123,\n \"allowNullRatioDenominator\": true\n },\n \"team\": \"<string>\",\n \"teamID\": \"<string>\",\n \"dryRun\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://statsigapi.net/console/v1/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["STATSIG-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"metricName\",\n \"type\": \"sum\",\n \"isVerified\": false,\n \"isReadOnly\": false,\n \"unitTypes\": [\n \"stableID\",\n \"userID\"\n ],\n \"metricEvents\": [\n {\n \"name\": \"event1\",\n \"type\": \"value\"\n }\n ],\n \"metricComponentMetrics\": [],\n \"description\": \"<string>\",\n \"directionality\": \"increase\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"isPermanent\": false,\n \"rollupTimeWindow\": \"custom\",\n \"customRollUpStart\": 1,\n \"customRollUpEnd\": 1,\n \"funnelEventList\": [\n {\n \"name\": \"event1\",\n \"type\": \"event_dau\"\n }\n ],\n \"warehouseNative\": {\n \"metricSourceName\": \"<string>\",\n \"criteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"waitForCohortWindow\": true,\n \"denominatorCriteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"denominatorCustomRollupEnd\": 123,\n \"denominatorCustomRollupStart\": 123,\n \"denominatorMetricSourceName\": \"<string>\",\n \"denominatorRollupTimeWindow\": \"<string>\",\n \"denominatorValueColumn\": \"<string>\",\n \"funnelCalculationWindow\": 123,\n \"funnelEvents\": [\n {\n \"criteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"metricSourceName\": \"<string>\",\n \"name\": \"<string>\",\n \"sessionIdentifierField\": \"<string>\"\n }\n ],\n \"metricDimensionColumns\": [\n \"<string>\"\n ],\n \"metricBakeDays\": 123,\n \"valueColumn\": \"<string>\",\n \"winsorizationHigh\": 0.5,\n \"winsorizationLow\": 0.5,\n \"cupedAttributionWindow\": 123,\n \"onlyIncludeUsersWithConversionEvent\": true,\n \"percentile\": 123,\n \"valueThreshold\": 123,\n \"cap\": 123,\n \"rollupTimeWindow\": \"<string>\",\n \"customRollUpStart\": 123,\n \"customRollUpEnd\": 123,\n \"allowNullRatioDenominator\": true\n },\n \"team\": \"<string>\",\n \"teamID\": \"<string>\",\n \"dryRun\": true\n}"
response = http.request(request)
puts response.read_body{
"message": "Metric created successfully.",
"data": {
"id": "TestMetricCapi::sum",
"name": "TestMetricCapi",
"directionality": "increase",
"type": "sum",
"description": "Capi Metric",
"isPermanent": false,
"isReadOnly": false,
"isHidden": false,
"isVerified": false,
"tags": [],
"creatorName": "CONSOLE API",
"creatorEmail": null,
"createdTime": 1720218271796,
"owner": {
"name": "CONSOLE API"
},
"lineage": {
"events": [
"add_to_cart"
],
"metrics": []
},
"team": "Console Team",
"unitTypes": [
"userID"
],
"metricEvents": [
{
"name": "add_to_cart",
"type": "metadata",
"criteria": []
}
]
}
}{
"status": 401,
"message": "This endpoint only accepts an active CONSOLE key, but an invalid key was sent. Key: console-xxxXXXxxxXXXxxx"
}Create Metric
curl --request POST \
--url https://statsigapi.net/console/v1/metrics \
--header 'Content-Type: application/json' \
--header 'STATSIG-API-KEY: <api-key>' \
--data '
{
"name": "metricName",
"type": "sum",
"isVerified": false,
"isReadOnly": false,
"unitTypes": [
"stableID",
"userID"
],
"metricEvents": [
{
"name": "event1",
"type": "value"
}
],
"metricComponentMetrics": [],
"description": "<string>",
"directionality": "increase",
"tags": [
"tag1",
"tag2"
],
"isPermanent": false,
"rollupTimeWindow": "custom",
"customRollUpStart": 1,
"customRollUpEnd": 1,
"funnelEventList": [
{
"name": "event1",
"type": "event_dau"
}
],
"warehouseNative": {
"metricSourceName": "<string>",
"criteria": [
{
"column": "<string>",
"values": [
"<string>"
],
"nullVacuousOverride": true
}
],
"waitForCohortWindow": true,
"denominatorCriteria": [
{
"column": "<string>",
"values": [
"<string>"
],
"nullVacuousOverride": true
}
],
"denominatorCustomRollupEnd": 123,
"denominatorCustomRollupStart": 123,
"denominatorMetricSourceName": "<string>",
"denominatorRollupTimeWindow": "<string>",
"denominatorValueColumn": "<string>",
"funnelCalculationWindow": 123,
"funnelEvents": [
{
"criteria": [
{
"column": "<string>",
"values": [
"<string>"
],
"nullVacuousOverride": true
}
],
"metricSourceName": "<string>",
"name": "<string>",
"sessionIdentifierField": "<string>"
}
],
"metricDimensionColumns": [
"<string>"
],
"metricBakeDays": 123,
"valueColumn": "<string>",
"winsorizationHigh": 0.5,
"winsorizationLow": 0.5,
"cupedAttributionWindow": 123,
"onlyIncludeUsersWithConversionEvent": true,
"percentile": 123,
"valueThreshold": 123,
"cap": 123,
"rollupTimeWindow": "<string>",
"customRollUpStart": 123,
"customRollUpEnd": 123,
"allowNullRatioDenominator": true
},
"team": "<string>",
"teamID": "<string>",
"dryRun": true
}
'import requests
url = "https://statsigapi.net/console/v1/metrics"
payload = {
"name": "metricName",
"type": "sum",
"isVerified": False,
"isReadOnly": False,
"unitTypes": ["stableID", "userID"],
"metricEvents": [
{
"name": "event1",
"type": "value"
}
],
"metricComponentMetrics": [],
"description": "<string>",
"directionality": "increase",
"tags": ["tag1", "tag2"],
"isPermanent": False,
"rollupTimeWindow": "custom",
"customRollUpStart": 1,
"customRollUpEnd": 1,
"funnelEventList": [
{
"name": "event1",
"type": "event_dau"
}
],
"warehouseNative": {
"metricSourceName": "<string>",
"criteria": [
{
"column": "<string>",
"values": ["<string>"],
"nullVacuousOverride": True
}
],
"waitForCohortWindow": True,
"denominatorCriteria": [
{
"column": "<string>",
"values": ["<string>"],
"nullVacuousOverride": True
}
],
"denominatorCustomRollupEnd": 123,
"denominatorCustomRollupStart": 123,
"denominatorMetricSourceName": "<string>",
"denominatorRollupTimeWindow": "<string>",
"denominatorValueColumn": "<string>",
"funnelCalculationWindow": 123,
"funnelEvents": [
{
"criteria": [
{
"column": "<string>",
"values": ["<string>"],
"nullVacuousOverride": True
}
],
"metricSourceName": "<string>",
"name": "<string>",
"sessionIdentifierField": "<string>"
}
],
"metricDimensionColumns": ["<string>"],
"metricBakeDays": 123,
"valueColumn": "<string>",
"winsorizationHigh": 0.5,
"winsorizationLow": 0.5,
"cupedAttributionWindow": 123,
"onlyIncludeUsersWithConversionEvent": True,
"percentile": 123,
"valueThreshold": 123,
"cap": 123,
"rollupTimeWindow": "<string>",
"customRollUpStart": 123,
"customRollUpEnd": 123,
"allowNullRatioDenominator": True
},
"team": "<string>",
"teamID": "<string>",
"dryRun": True
}
headers = {
"STATSIG-API-KEY": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'STATSIG-API-KEY': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'metricName',
type: 'sum',
isVerified: false,
isReadOnly: false,
unitTypes: ['stableID', 'userID'],
metricEvents: [{name: 'event1', type: 'value'}],
metricComponentMetrics: [],
description: '<string>',
directionality: 'increase',
tags: ['tag1', 'tag2'],
isPermanent: false,
rollupTimeWindow: 'custom',
customRollUpStart: 1,
customRollUpEnd: 1,
funnelEventList: [{name: 'event1', type: 'event_dau'}],
warehouseNative: {
metricSourceName: '<string>',
criteria: [{column: '<string>', values: ['<string>'], nullVacuousOverride: true}],
waitForCohortWindow: true,
denominatorCriteria: [{column: '<string>', values: ['<string>'], nullVacuousOverride: true}],
denominatorCustomRollupEnd: 123,
denominatorCustomRollupStart: 123,
denominatorMetricSourceName: '<string>',
denominatorRollupTimeWindow: '<string>',
denominatorValueColumn: '<string>',
funnelCalculationWindow: 123,
funnelEvents: [
{
criteria: [{column: '<string>', values: ['<string>'], nullVacuousOverride: true}],
metricSourceName: '<string>',
name: '<string>',
sessionIdentifierField: '<string>'
}
],
metricDimensionColumns: ['<string>'],
metricBakeDays: 123,
valueColumn: '<string>',
winsorizationHigh: 0.5,
winsorizationLow: 0.5,
cupedAttributionWindow: 123,
onlyIncludeUsersWithConversionEvent: true,
percentile: 123,
valueThreshold: 123,
cap: 123,
rollupTimeWindow: '<string>',
customRollUpStart: 123,
customRollUpEnd: 123,
allowNullRatioDenominator: true
},
team: '<string>',
teamID: '<string>',
dryRun: true
})
};
fetch('https://statsigapi.net/console/v1/metrics', 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://statsigapi.net/console/v1/metrics",
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' => 'metricName',
'type' => 'sum',
'isVerified' => false,
'isReadOnly' => false,
'unitTypes' => [
'stableID',
'userID'
],
'metricEvents' => [
[
'name' => 'event1',
'type' => 'value'
]
],
'metricComponentMetrics' => [
],
'description' => '<string>',
'directionality' => 'increase',
'tags' => [
'tag1',
'tag2'
],
'isPermanent' => false,
'rollupTimeWindow' => 'custom',
'customRollUpStart' => 1,
'customRollUpEnd' => 1,
'funnelEventList' => [
[
'name' => 'event1',
'type' => 'event_dau'
]
],
'warehouseNative' => [
'metricSourceName' => '<string>',
'criteria' => [
[
'column' => '<string>',
'values' => [
'<string>'
],
'nullVacuousOverride' => true
]
],
'waitForCohortWindow' => true,
'denominatorCriteria' => [
[
'column' => '<string>',
'values' => [
'<string>'
],
'nullVacuousOverride' => true
]
],
'denominatorCustomRollupEnd' => 123,
'denominatorCustomRollupStart' => 123,
'denominatorMetricSourceName' => '<string>',
'denominatorRollupTimeWindow' => '<string>',
'denominatorValueColumn' => '<string>',
'funnelCalculationWindow' => 123,
'funnelEvents' => [
[
'criteria' => [
[
'column' => '<string>',
'values' => [
'<string>'
],
'nullVacuousOverride' => true
]
],
'metricSourceName' => '<string>',
'name' => '<string>',
'sessionIdentifierField' => '<string>'
]
],
'metricDimensionColumns' => [
'<string>'
],
'metricBakeDays' => 123,
'valueColumn' => '<string>',
'winsorizationHigh' => 0.5,
'winsorizationLow' => 0.5,
'cupedAttributionWindow' => 123,
'onlyIncludeUsersWithConversionEvent' => true,
'percentile' => 123,
'valueThreshold' => 123,
'cap' => 123,
'rollupTimeWindow' => '<string>',
'customRollUpStart' => 123,
'customRollUpEnd' => 123,
'allowNullRatioDenominator' => true
],
'team' => '<string>',
'teamID' => '<string>',
'dryRun' => true
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"STATSIG-API-KEY: <api-key>"
],
]);
$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://statsigapi.net/console/v1/metrics"
payload := strings.NewReader("{\n \"name\": \"metricName\",\n \"type\": \"sum\",\n \"isVerified\": false,\n \"isReadOnly\": false,\n \"unitTypes\": [\n \"stableID\",\n \"userID\"\n ],\n \"metricEvents\": [\n {\n \"name\": \"event1\",\n \"type\": \"value\"\n }\n ],\n \"metricComponentMetrics\": [],\n \"description\": \"<string>\",\n \"directionality\": \"increase\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"isPermanent\": false,\n \"rollupTimeWindow\": \"custom\",\n \"customRollUpStart\": 1,\n \"customRollUpEnd\": 1,\n \"funnelEventList\": [\n {\n \"name\": \"event1\",\n \"type\": \"event_dau\"\n }\n ],\n \"warehouseNative\": {\n \"metricSourceName\": \"<string>\",\n \"criteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"waitForCohortWindow\": true,\n \"denominatorCriteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"denominatorCustomRollupEnd\": 123,\n \"denominatorCustomRollupStart\": 123,\n \"denominatorMetricSourceName\": \"<string>\",\n \"denominatorRollupTimeWindow\": \"<string>\",\n \"denominatorValueColumn\": \"<string>\",\n \"funnelCalculationWindow\": 123,\n \"funnelEvents\": [\n {\n \"criteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"metricSourceName\": \"<string>\",\n \"name\": \"<string>\",\n \"sessionIdentifierField\": \"<string>\"\n }\n ],\n \"metricDimensionColumns\": [\n \"<string>\"\n ],\n \"metricBakeDays\": 123,\n \"valueColumn\": \"<string>\",\n \"winsorizationHigh\": 0.5,\n \"winsorizationLow\": 0.5,\n \"cupedAttributionWindow\": 123,\n \"onlyIncludeUsersWithConversionEvent\": true,\n \"percentile\": 123,\n \"valueThreshold\": 123,\n \"cap\": 123,\n \"rollupTimeWindow\": \"<string>\",\n \"customRollUpStart\": 123,\n \"customRollUpEnd\": 123,\n \"allowNullRatioDenominator\": true\n },\n \"team\": \"<string>\",\n \"teamID\": \"<string>\",\n \"dryRun\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("STATSIG-API-KEY", "<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://statsigapi.net/console/v1/metrics")
.header("STATSIG-API-KEY", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"metricName\",\n \"type\": \"sum\",\n \"isVerified\": false,\n \"isReadOnly\": false,\n \"unitTypes\": [\n \"stableID\",\n \"userID\"\n ],\n \"metricEvents\": [\n {\n \"name\": \"event1\",\n \"type\": \"value\"\n }\n ],\n \"metricComponentMetrics\": [],\n \"description\": \"<string>\",\n \"directionality\": \"increase\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"isPermanent\": false,\n \"rollupTimeWindow\": \"custom\",\n \"customRollUpStart\": 1,\n \"customRollUpEnd\": 1,\n \"funnelEventList\": [\n {\n \"name\": \"event1\",\n \"type\": \"event_dau\"\n }\n ],\n \"warehouseNative\": {\n \"metricSourceName\": \"<string>\",\n \"criteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"waitForCohortWindow\": true,\n \"denominatorCriteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"denominatorCustomRollupEnd\": 123,\n \"denominatorCustomRollupStart\": 123,\n \"denominatorMetricSourceName\": \"<string>\",\n \"denominatorRollupTimeWindow\": \"<string>\",\n \"denominatorValueColumn\": \"<string>\",\n \"funnelCalculationWindow\": 123,\n \"funnelEvents\": [\n {\n \"criteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"metricSourceName\": \"<string>\",\n \"name\": \"<string>\",\n \"sessionIdentifierField\": \"<string>\"\n }\n ],\n \"metricDimensionColumns\": [\n \"<string>\"\n ],\n \"metricBakeDays\": 123,\n \"valueColumn\": \"<string>\",\n \"winsorizationHigh\": 0.5,\n \"winsorizationLow\": 0.5,\n \"cupedAttributionWindow\": 123,\n \"onlyIncludeUsersWithConversionEvent\": true,\n \"percentile\": 123,\n \"valueThreshold\": 123,\n \"cap\": 123,\n \"rollupTimeWindow\": \"<string>\",\n \"customRollUpStart\": 123,\n \"customRollUpEnd\": 123,\n \"allowNullRatioDenominator\": true\n },\n \"team\": \"<string>\",\n \"teamID\": \"<string>\",\n \"dryRun\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://statsigapi.net/console/v1/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["STATSIG-API-KEY"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"metricName\",\n \"type\": \"sum\",\n \"isVerified\": false,\n \"isReadOnly\": false,\n \"unitTypes\": [\n \"stableID\",\n \"userID\"\n ],\n \"metricEvents\": [\n {\n \"name\": \"event1\",\n \"type\": \"value\"\n }\n ],\n \"metricComponentMetrics\": [],\n \"description\": \"<string>\",\n \"directionality\": \"increase\",\n \"tags\": [\n \"tag1\",\n \"tag2\"\n ],\n \"isPermanent\": false,\n \"rollupTimeWindow\": \"custom\",\n \"customRollUpStart\": 1,\n \"customRollUpEnd\": 1,\n \"funnelEventList\": [\n {\n \"name\": \"event1\",\n \"type\": \"event_dau\"\n }\n ],\n \"warehouseNative\": {\n \"metricSourceName\": \"<string>\",\n \"criteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"waitForCohortWindow\": true,\n \"denominatorCriteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"denominatorCustomRollupEnd\": 123,\n \"denominatorCustomRollupStart\": 123,\n \"denominatorMetricSourceName\": \"<string>\",\n \"denominatorRollupTimeWindow\": \"<string>\",\n \"denominatorValueColumn\": \"<string>\",\n \"funnelCalculationWindow\": 123,\n \"funnelEvents\": [\n {\n \"criteria\": [\n {\n \"column\": \"<string>\",\n \"values\": [\n \"<string>\"\n ],\n \"nullVacuousOverride\": true\n }\n ],\n \"metricSourceName\": \"<string>\",\n \"name\": \"<string>\",\n \"sessionIdentifierField\": \"<string>\"\n }\n ],\n \"metricDimensionColumns\": [\n \"<string>\"\n ],\n \"metricBakeDays\": 123,\n \"valueColumn\": \"<string>\",\n \"winsorizationHigh\": 0.5,\n \"winsorizationLow\": 0.5,\n \"cupedAttributionWindow\": 123,\n \"onlyIncludeUsersWithConversionEvent\": true,\n \"percentile\": 123,\n \"valueThreshold\": 123,\n \"cap\": 123,\n \"rollupTimeWindow\": \"<string>\",\n \"customRollUpStart\": 123,\n \"customRollUpEnd\": 123,\n \"allowNullRatioDenominator\": true\n },\n \"team\": \"<string>\",\n \"teamID\": \"<string>\",\n \"dryRun\": true\n}"
response = http.request(request)
puts response.read_body{
"message": "Metric created successfully.",
"data": {
"id": "TestMetricCapi::sum",
"name": "TestMetricCapi",
"directionality": "increase",
"type": "sum",
"description": "Capi Metric",
"isPermanent": false,
"isReadOnly": false,
"isHidden": false,
"isVerified": false,
"tags": [],
"creatorName": "CONSOLE API",
"creatorEmail": null,
"createdTime": 1720218271796,
"owner": {
"name": "CONSOLE API"
},
"lineage": {
"events": [
"add_to_cart"
],
"metrics": []
},
"team": "Console Team",
"unitTypes": [
"userID"
],
"metricEvents": [
{
"name": "add_to_cart",
"type": "metadata",
"criteria": []
}
]
}
}{
"status": 401,
"message": "This endpoint only accepts an active CONSOLE key, but an invalid key was sent. Key: console-xxxXXXxxxXXXxxx"
}Authorizations
Headers
Optional header to respect review settings for mutation endpoints.
Body
The name of the new metric, which identifies it within the system.
4 - 200^[a-zA-Z0-9_.\-()/ %:]*$"metricName"
The type of the metric. Allowed values include sum, ratio, mean, event_count_sum, composite, composite_sum, undefined, funnel, user_warehouse.
ratio, sum, composite, mean, event_count_custom, event_user, funnel, undefined, setup_incomplete, composite_sum, import_window, user_warehouse "sum"
Marks the metric as verified for internal trustworthiness.
false
Set to true to make the metric definition editable only from the Console API.
false
Array of unit types associated with the metric, such as stableID or userID.
["stableID", "userID"]
An array of event definitions used to compute the metric.
Show child attributes
Show child attributes
[{ "name": "event1", "type": "value" }]
List of input metrics used to calculate the new metric for composite types.
Show child attributes
Show child attributes
[]
A description of the new metric, providing context and purpose.
1000Indicates the desired change direction for the metric. Use "increase" for positive changes and "decrease" for negative changes.
increase, decrease "increase"
Tags associated with the metric for categorization and searchability.
["tag1", "tag2"]
Indicates whether the metric is permanent and should not be deleted.
false
Time window for the metric rollup. Specify "custom" for a customized time window.
"custom"
Custom time window start date in days since exposure.
1
Custom time window end date in days since exposure.
1
List of events used to create funnel metrics.
Show child attributes
Show child attributes
Specifies whether to count events or distinct users for the funnel metric.
events, users Defines warehouse native metrics for advanced configurations.
Show child attributes
Show child attributes
The team associated with the metric, applicable for enterprise environments.
The team ID associated with the metric, applicable for enterprise environments.
Skips persisting the metric (used to validate that inputs are correct)

