Skip to content

POST /v1/projects/{projectId}/metrics/query

Runs read-only SQL over the Project's message_events or call_events table. Get the SQL schema for supported columns, capabilities, and limits.

photon.projects.queryMessageMetrics(input: QueryMessageMetricsInput, options?: RequestOptions): Promise<QueryMessageMetricsOutput>
import { Photon } from "@photon-ai/api";

const photon = new Photon({
  headers: { Authorization: `Bearer ${process.env.PHOTON_API_TOKEN}` },
});
const result = await photon.projects.queryMessageMetrics({
  path: {
    projectId: "projectId",
  },
  body: {
    sql: "sql",
  },
});
{
  "columns": [
    {
      "name": "string",
      "type": "string"
    }
  ],
  "rows": [
    [
      "string"
    ]
  ],
  "statistics": {
    "bytesRead": 0,
    "elapsedSeconds": 0,
    "rowsRead": 0
  }
}

Parameters

projectIdstringrequired
x-photon-versionstring (date)

API schema date. Defaults to the latest served version; resolves to the latest served date on or before this value.

Body

parametersobject
sqlstringrequired

Returns

200 Dynamic SQL columns and rows followed by bounded ClickHouse read statistics. QueryMessageMetricsResponse

columnsarray of MessageMetricsQueryColumnrequired
rowsarray of array of objectrequired
statisticsMessageMetricsQueryStatisticsrequired