Get metric data and aggregations
curl --request GET \
--url https://eu-gcp-api.vg-stuff.com/v3/agents/{agentId}/custom-metrics/{metricKey}/data \
--header 'Authorization: Bearer <token>'import requests
url = "https://eu-gcp-api.vg-stuff.com/v3/agents/{agentId}/custom-metrics/{metricKey}/data"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://eu-gcp-api.vg-stuff.com/v3/agents/{agentId}/custom-metrics/{metricKey}/data', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://eu-gcp-api.vg-stuff.com/v3/agents/{agentId}/custom-metrics/{metricKey}/data",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://eu-gcp-api.vg-stuff.com/v3/agents/{agentId}/custom-metrics/{metricKey}/data"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://eu-gcp-api.vg-stuff.com/v3/agents/{agentId}/custom-metrics/{metricKey}/data")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://eu-gcp-api.vg-stuff.com/v3/agents/{agentId}/custom-metrics/{metricKey}/data")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"key": "<string>",
"type": "numeric",
"totalDataPoints": 123,
"average": 123,
"sum": 123,
"min": 123,
"max": 123,
"counts": {},
"timeSeries": [
{
"ts": 123,
"value": "<string>",
"convo_id": "<string>"
}
]
}
}{
"message": "<string>",
"code": "<string>",
"issues": [
{
"message": "<string>"
}
]
}Custom Metrics
Get Metric Data
Retrieve aggregated data and analytics for a specific metric
GET
/
agents
/
{agentId}
/
custom-metrics
/
{metricKey}
/
data
Get metric data and aggregations
curl --request GET \
--url https://eu-gcp-api.vg-stuff.com/v3/agents/{agentId}/custom-metrics/{metricKey}/data \
--header 'Authorization: Bearer <token>'import requests
url = "https://eu-gcp-api.vg-stuff.com/v3/agents/{agentId}/custom-metrics/{metricKey}/data"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://eu-gcp-api.vg-stuff.com/v3/agents/{agentId}/custom-metrics/{metricKey}/data', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://eu-gcp-api.vg-stuff.com/v3/agents/{agentId}/custom-metrics/{metricKey}/data",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://eu-gcp-api.vg-stuff.com/v3/agents/{agentId}/custom-metrics/{metricKey}/data"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://eu-gcp-api.vg-stuff.com/v3/agents/{agentId}/custom-metrics/{metricKey}/data")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://eu-gcp-api.vg-stuff.com/v3/agents/{agentId}/custom-metrics/{metricKey}/data")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"key": "<string>",
"type": "numeric",
"totalDataPoints": 123,
"average": 123,
"sum": 123,
"min": 123,
"max": 123,
"counts": {},
"timeSeries": [
{
"ts": 123,
"value": "<string>",
"convo_id": "<string>"
}
]
}
}{
"message": "<string>",
"code": "<string>",
"issues": [
{
"message": "<string>"
}
]
}Overview
Fetches aggregated analytics data for a specific metric within a time range. Returns statistical summaries and optional time-series data points.Numeric Metrics
For number-type metrics, the response includes statistical aggregations:{
"success": true,
"data": {
"key": "customer_satisfaction",
"type": "numeric",
"average": 8.5,
"sum": 425,
"min": 5,
"max": 10,
"totalDataPoints": 50,
"timeSeries": [
{
"ts": 1640000000,
"value": 8,
"convo_id": "convo_123"
}
]
}
}
Available Aggregations
- average: Mean value across all data points
- sum: Total sum of all values
- min: Minimum recorded value
- max: Maximum recorded value
Categorical Metrics
For boolean, enum, and string types, the response includes count distributions:{
"success": true,
"data": {
"key": "sentiment",
"type": "categorical",
"counts": {
"positive": 30,
"negative": 10,
"neutral": 10
},
"totalDataPoints": 50,
"timeSeries": [...]
}
}
Categories are automatically limited to the top 10 most frequent values. Less frequent values are grouped into “other”.
Time-Series Data
ThetimeSeries array provides individual data points with timestamps and conversation IDs:
// Each time-series point
{
"ts": 1640000000, // Unix timestamp (seconds)
"value": 8, // Metric value
"convo_id": "convo_123" // Associated conversation ID
}
Set
includeTimeSeries: false to reduce response size when you only need aggregated statistics.Time Range Examples
Last 24 Hours
const now = Math.floor(Date.now() / 1000);
const yesterday = now - (24 * 60 * 60);
const data = await fetch(
`/v3/agents/{agentId}/custom-metrics/customer_satisfaction/data?startTs=${yesterday}&endTs=${now}`
);
Last 7 Days
const now = Math.floor(Date.now() / 1000);
const weekAgo = now - (7 * 24 * 60 * 60);
const data = await fetch(
`/v3/agents/{agentId}/custom-metrics/nps_score/data?startTs=${weekAgo}&endTs=${now}`
);
Current Month
const now = new Date();
const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
const startTs = Math.floor(startOfMonth.getTime() / 1000);
const endTs = Math.floor(Date.now() / 1000);
Use Cases
- Dashboard Analytics: Power real-time metric dashboards
- Trend Analysis: Identify patterns over time
- Performance Reports: Generate periodic performance summaries
- Alerts: Trigger notifications based on metric thresholds
- A/B Testing: Compare metric performance across different periods
Performance Tips
- Use smaller time ranges for faster queries
- Disable
includeTimeSerieswhen you don’t need individual data points - Cache results for frequently accessed date ranges
- Query during off-peak hours for large historical data requests
No Data Response
When no data points exist for the time range:{
"success": true,
"data": {
"key": "customer_satisfaction",
"type": "numeric",
"totalDataPoints": 0,
"timeSeries": []
}
}
