curl --request POST \
--url https://statsigapi.net/console/v1/metrics/metric_source \
--header 'Content-Type: application/json' \
--header 'STATSIG-API-KEY: <api-key>' \
--data '
{
"name": "<string>",
"sql": "<string>",
"timestampColumn": "<string>",
"idTypeMapping": [
{
"statsigUnitID": "<string>",
"column": "<string>"
}
],
"description": "<string>",
"tags": [
"<string>"
],
"timestampAsDay": true,
"sourceType": "table",
"tableName": "<string>",
"customFieldMapping": [
{
"key": "<string>",
"formula": "<string>"
}
],
"isReadOnly": true,
"owner": {
"ownerID": "user123",
"ownerType": "USER",
"ownerName": "John Doe",
"ownerEmail": "owner123@test.com"
},
"dryRun": true
}
'{
"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"
}
}curl --request POST \
--url https://statsigapi.net/console/v1/metrics/metric_source \
--header 'Content-Type: application/json' \
--header 'STATSIG-API-KEY: <api-key>' \
--data '
{
"name": "<string>",
"sql": "<string>",
"timestampColumn": "<string>",
"idTypeMapping": [
{
"statsigUnitID": "<string>",
"column": "<string>"
}
],
"description": "<string>",
"tags": [
"<string>"
],
"timestampAsDay": true,
"sourceType": "table",
"tableName": "<string>",
"customFieldMapping": [
{
"key": "<string>",
"formula": "<string>"
}
],
"isReadOnly": true,
"owner": {
"ownerID": "user123",
"ownerType": "USER",
"ownerName": "John Doe",
"ownerEmail": "owner123@test.com"
},
"dryRun": true
}
'{
"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"
}
}Optional header to respect review settings for mutation endpoints.
The name of the metric source, serving as its primary identifier.
The SQL query or statement used to extract data from the metric source.
The name of the column containing timestamp data for the metric source.
Array defining the mapping between Statsig unit IDs and their respective source columns.
Show child attributes
An optional description for the metric source, providing context and details about its purpose and usage.
Optional array of tags to categorize the metric source, facilitating easier organization and retrieval.
Indicates whether the timestamp should be treated as a day-level granularity.
The type of source, indicating whether it is a database table or a custom query.
table, query The name of the database table if the source type is "table".
Optional array defining mappings for custom fields using specific formulas.
Show child attributes
Specifies if the source can only be edited via the Console API.
Schema for owner data including ID, type, name. Note that if Entity is created by CONSOLE API, owner will be undefined.
Show child attributes
{
"ownerID": "user123",
"ownerType": "USER",
"ownerName": "John Doe",
"ownerEmail": "owner123@test.com"
}Skips persisting the metric source (used to validate that inputs are correct)