Skip to main content
POST
/
metrics
cURL
curl -X POST https://api.growthbook.io/api/v1/metrics \
  -d '{ "datasourceId": "ds_abc123", ... }'
  -u secret_abc123DEF456:
{
  "metric": {
    "id": "<string>",
    "managedBy": "",
    "dateCreated": "<string>",
    "dateUpdated": "<string>",
    "owner": "<string>",
    "datasourceId": "<string>",
    "name": "<string>",
    "description": "<string>",
    "type": "binomial",
    "tags": [
      "<string>"
    ],
    "projects": [
      "<string>"
    ],
    "archived": true,
    "behavior": {
      "goal": "increase",
      "windowSettings": {
        "type": "none",
        "delayValue": 123,
        "delayUnit": "minutes",
        "windowValue": 123,
        "windowUnit": "minutes"
      },
      "riskThresholdSuccess": 123,
      "riskThresholdDanger": 123,
      "minPercentChange": 123,
      "maxPercentChange": 123,
      "minSampleSize": 123,
      "targetMDE": 123,
      "cappingSettings": {
        "type": "none",
        "value": 123,
        "ignoreZeros": true
      },
      "cap": 123,
      "capping": "absolute",
      "capValue": 123,
      "priorSettings": {
        "override": true,
        "proper": true,
        "mean": 123,
        "stddev": 123
      },
      "conversionWindowStart": 123,
      "conversionWindowEnd": 123
    },
    "sql": {
      "identifierTypes": [
        "<string>"
      ],
      "conversionSQL": "<string>",
      "userAggregationSQL": "<string>",
      "denominatorMetricId": "<string>"
    },
    "sqlBuilder": {
      "identifierTypeColumns": [
        {
          "identifierType": "<string>",
          "columnName": "<string>"
        }
      ],
      "tableName": "<string>",
      "valueColumnName": "<string>",
      "timestampColumnName": "<string>",
      "conditions": [
        {
          "column": "<string>",
          "operator": "<string>",
          "value": "<string>"
        }
      ]
    },
    "mixpanel": {
      "eventName": "<string>",
      "eventValue": "<string>",
      "userAggregation": "<string>",
      "conditions": [
        {
          "property": "<string>",
          "operator": "<string>",
          "value": "<string>"
        }
      ]
    }
  }
}

Documentation Index

Fetch the complete documentation index at: https://growthbook-preview.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

If using Bearer auth, pass the Secret Key as the token:

curl https://api.growthbook.io/api/v1 \
-H "Authorization: Bearer secret_abc123DEF456"

Body

application/json
datasourceId
string
required

ID for the DataSource

name
string
required

Name of the metric

type
enum<string>
required

Type of metric. See Metrics documentation

Available options:
binomial,
count,
duration,
revenue
managedBy
enum<string>

Where this metric must be managed from. If not set (empty string), it can be managed from anywhere. If set to "api", it can be managed via the API only.

Available options:
,
api
owner
any
description
string

Description of the metric

tags
string[]

List of tags

projects
string[]

List of project IDs for projects that can access this metric

archived
boolean
behavior
object
sql
object

Preferred way to define SQL. Only one of sql, sqlBuilder or mixpanel allowed, and at least one must be specified.

sqlBuilder
object

An alternative way to specify a SQL metric, rather than a full query. Using sql is preferred to sqlBuilder. Only one of sql, sqlBuilder or mixpanel allowed, and at least one must be specified.

mixpanel
object

Only use for MixPanel (non-SQL) Data Sources. Only one of sql, sqlBuilder or mixpanel allowed, and at least one must be specified.

Response

200 - application/json

Success

metric
object
required