Metrics
Metrics

Creates a metric. Set localMetric to attach it to an experiment or gate as a local metric. Warehouse-native dimension filters and breakdown columns use warehouseNative.

post/console/v1/metrics

Request

  • Base URL
    https://statsigapi.net
  • URL
    https://statsigapi.net/console/v1/metrics
  • Auth
    API key in header STATSIG-API-KEY

Request body

namestring required

The name of the new metric, which identifies it within the system.

type'ratio' | 'mean' | 'event_count_custom' | 'event_user' | 'funnel' | 'composite' | 'composite_sum' | 'sum' | 'user_warehouse' | 'percentile' | 'latest_value' required
isVerifiedboolean

Marks the metric as verified for internal trustworthiness.

isReadOnlyboolean

Set to true to make the metric definition editable only from the Console API.

unitTypesstring[]

Array of unit types associated with the metric, such as stableID or userID.

descriptionstring

A description of the new metric, providing context and purpose.

directionality'increase' | 'decrease'

Indicates the desired change direction for the metric. Use "increase" for positive changes and "decrease" for negative changes.

isPermanentboolean

Indicates whether the metric is permanent and should not be deleted.

rollupTimeWindowstring

Time window for the metric rollup. Specify "custom" for a customized time window.

customRollUpStartnumber double

Custom time window start date in days since exposure.

customRollUpEndnumber double

Custom time window end date in days since exposure.

percentilenumber double

Percentile value for percentile metrics.

funnelCountDistinct'events' | 'users'

Specifies whether to count events or distinct users for the funnel metric.

teamstring nullable

The team associated with the metric, applicable for enterprise environments.

teamIDstring nullable

The team ID associated with the metric, applicable for enterprise environments.

dryRunboolean

Skips persisting the metric (used to validate that inputs are correct)

Example request

{
  "name": "metricName",
  "type": "sum",
  "unitTypes": [
    "stableID",
    "userID"
  ],
  "metricEvents": [
    {
      "name": "event1",
      "type": "value"
    }
  ],
  "metricComponentMetrics": [],
  "directionality": "increase",
  "rollupTimeWindow": "custom",
  "customRollUpStart": 1,
  "customRollUpEnd": 1,
  "percentile": 0.95,
  "funnelEventList": [
    {
      "name": "event1",
      "type": "event_dau"
    }
  ],
  "warehouseNative": {
    "metricDimensionLimits": [
      {
        "limit": 10
      }
    ],
    "loadingWindow": 90
  },
  "localMetric": {
    "configName": "purchase_experiment",
    "section": "primary",
    "clusterUnitType": "user_id"
  }
}

Response

Create metric response

messagestring required

A simple string explaining the result of the operation.

Example response

{
  "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": "John Doe",
      "ownerID": "user123",
      "ownerType": "USER",
      "ownerName": "John Doe",
      "ownerEmail": "owner123@test.com"
    },
    "lineage": {
      "events": [
        "add_to_cart"
      ],
      "metrics": []
    },
    "team": "Console Team",
    "unitTypes": [
      "userID"
    ],
    "metricEvents": [
      {
        "name": "add_to_cart",
        "type": "metadata",
        "criteria": []
      }
    ],
    "permalink": "https://console.statsig.com/company_id/metrics/metrics_catalog/TestMetricCapi/sum"
  }
}

Changes

    • info

      added the new optional request property

    • info

      added the optional property // to the response with the status

    • breaking

      removed the enum value undefined of the request property

    • breaking

      the / request property type changed from number to integer, and format from double to int64

    • breaking

      the / request property type changed from number to integer, and format from double to int64

    • breaking

      the / request property type changed from number to integer, and format from double to int64

    • breaking

      the / request property type changed from number to integer, and format from double to int64

    • breaking

      the / request property type changed from number to integer, and format from double to int64

    • breaking

      the / request property type changed from number to integer, and format from double to int64

    • breaking

      the / request property type changed from number to integer, and format from double to int64

    • breaking

      the / request property type changed from number to integer, and format from double to int64

    • breaking

      removed the required property /// from the response with the status

    • warning

      the / request property's exclusiveMinimum was set to true

    • warning

      the / request property's exclusiveMinimum was set to true

    • warning

      the / request property's exclusiveMinimum was set to true

    • warning

      the / request property's max was set to 1.00

    • warning

      the / request property's min was set to 0.00

    • warning

      the / request property's min was set to 0.00

    • warning

      the / request property's min was set to 0.00

    • warning

      the / request property's min was set to 0.00

    • warning

      the / request property's min was set to 0.00

    • warning

      the / request property's min was set to 0.00

    • warning

      the / request property's min was set to 0.00

    • warning

      the / request property's min was set to 0.00

    • warning

      the / request property's min was set to 0.00

    • warning

      the / request property's min was set to 0.00