Skip to main content
POST
/
api
/
v2
/
projects
/
{projectUuid}
/
query
/
metric-query
Execute metric query
curl --request POST \
  --url http://api/v2/projects/{projectUuid}/query/metric-query \
  --header 'Content-Type: application/json' \
  --data '
{
  "parameters": {},
  "invalidateCache": true,
  "context": "dashboardView",
  "pivotConfiguration": {
    "sortBy": [
      {
        "direction": "ASC",
        "reference": "<string>"
      }
    ],
    "groupByColumns": [
      {
        "reference": "<string>"
      }
    ],
    "valuesColumns": [
      {
        "aggregation": "sum",
        "reference": "<string>"
      }
    ],
    "indexColumn": {
      "type": "time",
      "reference": "<string>"
    }
  },
  "dateZoom": {
    "xAxisFieldId": "<string>",
    "granularity": "Day"
  },
  "query": {
    "dateZoom": {
      "xAxisFieldId": "<string>",
      "granularity": "Day"
    },
    "filters": {
      "tableCalculations": "<any>",
      "metrics": "<any>",
      "dimensions": "<any>"
    },
    "dimensions": [
      "<string>"
    ],
    "metrics": [
      "<string>"
    ],
    "tableCalculations": [
      {
        "type": "number",
        "format": {
          "type": "default",
          "round": 123,
          "separator": "default",
          "currency": "<string>",
          "compact": "thousands",
          "prefix": "<string>",
          "suffix": "<string>",
          "timeInterval": "RAW",
          "custom": "<string>"
        },
        "sql": "<string>",
        "displayName": "<string>",
        "name": "<string>",
        "index": 123
      }
    ],
    "exploreName": "<string>",
    "sorts": [
      {
        "nullsFirst": true,
        "descending": true,
        "fieldId": "<string>"
      }
    ],
    "limit": 123,
    "additionalMetrics": [
      {
        "label": "<string>",
        "type": "percentile",
        "description": "<string>",
        "sql": "<string>",
        "hidden": true,
        "round": 123,
        "compact": "thousands",
        "format": "km",
        "table": "<string>",
        "name": "<string>",
        "index": 123,
        "filters": [
          {
            "values": [
              "<any>"
            ],
            "operator": "isNull",
            "id": "<string>",
            "target": {
              "fieldRef": "<string>"
            },
            "settings": "<any>",
            "disabled": true,
            "required": true
          }
        ],
        "baseDimensionName": "<string>",
        "uuid": "<string>",
        "percentile": 123,
        "formatOptions": {
          "type": "default",
          "round": 123,
          "separator": "default",
          "currency": "<string>",
          "compact": "thousands",
          "prefix": "<string>",
          "suffix": "<string>",
          "timeInterval": "RAW",
          "custom": "<string>"
        }
      }
    ],
    "customDimensions": [
      {
        "id": "<string>",
        "name": "<string>",
        "table": "<string>",
        "type": "bin",
        "dimensionId": "<string>",
        "binType": "fixed_number",
        "binNumber": 123,
        "binWidth": 123,
        "customRange": [
          {
            "to": 123,
            "from": 123
          }
        ]
      }
    ],
    "metadata": {
      "hasADateDimension": {}
    },
    "timezone": "<string>",
    "metricOverrides": {}
  }
}
'
{
  "results": {
    "usedParametersValues": {},
    "parameterReferences": [
      "<string>"
    ],
    "cacheMetadata": {
      "cacheHit": true,
      "cacheKey": "<string>",
      "cacheExpiresAt": "2023-11-07T05:31:56Z",
      "cacheUpdatedTime": "2023-11-07T05:31:56Z"
    },
    "queryUuid": "<string>",
    "warnings": [
      {
        "tables": [
          "<string>"
        ],
        "fields": [
          "<string>"
        ],
        "message": "<string>"
      }
    ],
    "fields": {},
    "metricQuery": {
      "metadata": {
        "hasADateDimension": {
          "name": "<string>",
          "label": "<string>",
          "table": "<string>"
        }
      },
      "timezone": "<string>",
      "metricOverrides": {},
      "customDimensions": [
        {
          "id": "<string>",
          "name": "<string>",
          "table": "<string>",
          "type": "bin",
          "dimensionId": "<string>",
          "binType": "fixed_number",
          "binNumber": 123,
          "binWidth": 123,
          "customRange": [
            {
              "to": "<any>",
              "from": "<any>"
            }
          ]
        }
      ],
      "additionalMetrics": [
        {
          "label": "<string>",
          "type": "percentile",
          "description": "<string>",
          "sql": "<string>",
          "hidden": true,
          "round": 123,
          "compact": "thousands",
          "format": "km",
          "table": "<string>",
          "name": "<string>",
          "index": 123,
          "filters": [
            {
              "values": [
                "<any>"
              ],
              "operator": "isNull",
              "id": "<string>",
              "target": {
                "fieldRef": "<string>"
              },
              "settings": "<any>",
              "disabled": true,
              "required": true
            }
          ],
          "baseDimensionName": "<string>",
          "uuid": "<string>",
          "percentile": 123,
          "formatOptions": {
            "type": "default",
            "round": 123,
            "separator": "default",
            "currency": "<string>",
            "compact": "thousands",
            "prefix": "<string>",
            "suffix": "<string>",
            "timeInterval": "RAW",
            "custom": "<string>"
          }
        }
      ],
      "tableCalculations": [
        {
          "type": "number",
          "format": {
            "type": "default",
            "round": 123,
            "separator": "default",
            "currency": "<string>",
            "compact": "thousands",
            "prefix": "<string>",
            "suffix": "<string>",
            "timeInterval": "RAW",
            "custom": "<string>"
          },
          "sql": "<string>",
          "displayName": "<string>",
          "name": "<string>",
          "index": 123
        }
      ],
      "limit": 123,
      "sorts": [
        {
          "nullsFirst": true,
          "descending": true,
          "fieldId": "<string>"
        }
      ],
      "filters": {
        "tableCalculations": {
          "or": [
            "<any>"
          ],
          "id": "<string>"
        },
        "metrics": {
          "or": [
            "<any>"
          ],
          "id": "<string>"
        },
        "dimensions": {
          "or": [
            "<any>"
          ],
          "id": "<string>"
        }
      },
      "metrics": [
        "<string>"
      ],
      "dimensions": [
        "<string>"
      ],
      "exploreName": "<string>"
    }
  },
  "status": "ok"
}

Path Parameters

projectUuid
string
required

Body

application/json
query
object
required

From T, pick a set of properties whose keys are in the union K

parameters
object

Construct a type with a set of properties K of type T

invalidateCache
boolean
context
enum<string>
Available options:
dashboardView,
autorefreshedDashboard,
exploreView,
filterAutocomplete,
chartView,
chartHistory,
sqlChartView,
sqlRunner,
viewUnderlyingData,
alert,
scheduledDelivery,
csvDownload,
gsheets,
scheduledGsheetsChart,
scheduledGsheetsDashboard,
scheduledChart,
scheduledDashboard,
calculateTotal,
calculateSubtotal,
embed,
ai,
mcp,
api,
cli,
metricsExplorer
pivotConfiguration
object
dateZoom
object

Response

Success

results
object
required
status
enum<string>
required
Available options:
ok