v2

latestOpenAPI 3.0.02026-08-073221853.1 MB
Metrics
Metrics (Warehouse Native)

Create Metric Source

post/console/v1/metrics/metric_source

Request body

namestring required

The name of the source, serving as its primary identifier.

descriptionstring

An optional description for the source, providing context and details about its purpose and usage.

tagsstring[]

Optional array of tags to categorize the source, facilitating easier organization and retrieval.

sqlstring required

The SQL query or statement used to extract data from the source.

timestampColumnstring required

The name of the column containing timestamp data for the source.

timestampAsDayboolean

Indicates whether the timestamp should be treated as a day-level granularity.

sourceType'table' | 'query'

The type of source, indicating whether it is a database table or a custom query.

tableNamestring

The name of the database table if the source type is "table".

datePartitionColumnstring

The name of the date partition column if the source type is "table". Can be undefined.

isReadOnlyboolean

Specifies if the source can only be edited via the Console API.

isVerifiedboolean

Marks the metric source as verified, indicating trustworthiness within the organization.

disableCUREboolean

Disable CURE for all metrics built from this metric source

teamstring nullable

Optional field indicating the team name responsible for the metric source, aiding in accountability and management.

teamIDstring nullable

Optional field indicating the team ID responsible for the metric source, aiding in accountability and management.

dryRunboolean

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

skip_validationboolean

Skips running SQL validation for the source. Requires all_columns and column_types when true. Availability is gated.

all_columnsstring[]

Column names to persist when skip_validation is true. Optional otherwise.

column_typesstring[]

Column types aligned with all_columns when skip_validation is true. Optional otherwise.

Example request

{
  "owner": {
    "ownerID": "user123",
    "ownerType": "USER",
    "ownerName": "John Doe",
    "ownerEmail": "owner123@test.com"
  }
}

Response

Create metric source response

messagestring required

A simple string explaining the result of the operation.

Example response

{
  "message": "Metric source created successfully.",
  "data": {
    "name": "test_metric_source2",
    "description": "Test description for metric source",
    "tags": [
      "non_production"
    ],
    "sql": "SELECT * FROM `shoppy-sales.logging.events`",
    "timestampColumn": "ts",
    "timestampAsDay": true,
    "idTypeMapping": [
      {
        "statsigUnitID": "userID",
        "column": "user_id"
      }
    ],
    "sourceType": "table",
    "tableName": "shoppy-sales.logging.events"
  }
}