curl --request POST \
--url https://api.meetsquad.ai/organisations/{orgId}/workspaces/{workspaceId}/metrics \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "Daily Active Users",
"ownerId": "<string>",
"description": "Number of unique users who performed any action in the last 24 hours",
"unit": "users",
"type": "custom",
"targetValue": 100,
"targetDirection": "up",
"currentValue": 150,
"previousValue": 140,
"periodType": "calendar",
"periodValue": "month",
"timeseries": [
{
"date": "2023-11-07T05:31:56Z",
"value": 85
}
],
"relatedOutcomes": [
"<unknown>"
],
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"outcomeIds": [
"7b9e5d2c-f314-48a9-be56-9843a2f6c019"
]
}
'import requests
url = "https://api.meetsquad.ai/organisations/{orgId}/workspaces/{workspaceId}/metrics"
payload = {
"title": "Daily Active Users",
"ownerId": "<string>",
"description": "Number of unique users who performed any action in the last 24 hours",
"unit": "users",
"type": "custom",
"targetValue": 100,
"targetDirection": "up",
"currentValue": 150,
"previousValue": 140,
"periodType": "calendar",
"periodValue": "month",
"timeseries": [
{
"date": "2023-11-07T05:31:56Z",
"value": 85
}
],
"relatedOutcomes": ["<unknown>"],
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"outcomeIds": ["7b9e5d2c-f314-48a9-be56-9843a2f6c019"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
title: 'Daily Active Users',
ownerId: '<string>',
description: 'Number of unique users who performed any action in the last 24 hours',
unit: 'users',
type: 'custom',
targetValue: 100,
targetDirection: 'up',
currentValue: 150,
previousValue: 140,
periodType: 'calendar',
periodValue: 'month',
timeseries: [{date: '2023-11-07T05:31:56Z', value: 85}],
relatedOutcomes: ['<unknown>'],
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
outcomeIds: ['7b9e5d2c-f314-48a9-be56-9843a2f6c019']
})
};
fetch('https://api.meetsquad.ai/organisations/{orgId}/workspaces/{workspaceId}/metrics', 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://api.meetsquad.ai/organisations/{orgId}/workspaces/{workspaceId}/metrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'title' => 'Daily Active Users',
'ownerId' => '<string>',
'description' => 'Number of unique users who performed any action in the last 24 hours',
'unit' => 'users',
'type' => 'custom',
'targetValue' => 100,
'targetDirection' => 'up',
'currentValue' => 150,
'previousValue' => 140,
'periodType' => 'calendar',
'periodValue' => 'month',
'timeseries' => [
[
'date' => '2023-11-07T05:31:56Z',
'value' => 85
]
],
'relatedOutcomes' => [
'<unknown>'
],
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'outcomeIds' => [
'7b9e5d2c-f314-48a9-be56-9843a2f6c019'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.meetsquad.ai/organisations/{orgId}/workspaces/{workspaceId}/metrics"
payload := strings.NewReader("{\n \"title\": \"Daily Active Users\",\n \"ownerId\": \"<string>\",\n \"description\": \"Number of unique users who performed any action in the last 24 hours\",\n \"unit\": \"users\",\n \"type\": \"custom\",\n \"targetValue\": 100,\n \"targetDirection\": \"up\",\n \"currentValue\": 150,\n \"previousValue\": 140,\n \"periodType\": \"calendar\",\n \"periodValue\": \"month\",\n \"timeseries\": [\n {\n \"date\": \"2023-11-07T05:31:56Z\",\n \"value\": 85\n }\n ],\n \"relatedOutcomes\": [\n \"<unknown>\"\n ],\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"outcomeIds\": [\n \"7b9e5d2c-f314-48a9-be56-9843a2f6c019\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.meetsquad.ai/organisations/{orgId}/workspaces/{workspaceId}/metrics")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"Daily Active Users\",\n \"ownerId\": \"<string>\",\n \"description\": \"Number of unique users who performed any action in the last 24 hours\",\n \"unit\": \"users\",\n \"type\": \"custom\",\n \"targetValue\": 100,\n \"targetDirection\": \"up\",\n \"currentValue\": 150,\n \"previousValue\": 140,\n \"periodType\": \"calendar\",\n \"periodValue\": \"month\",\n \"timeseries\": [\n {\n \"date\": \"2023-11-07T05:31:56Z\",\n \"value\": 85\n }\n ],\n \"relatedOutcomes\": [\n \"<unknown>\"\n ],\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"outcomeIds\": [\n \"7b9e5d2c-f314-48a9-be56-9843a2f6c019\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.meetsquad.ai/organisations/{orgId}/workspaces/{workspaceId}/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"title\": \"Daily Active Users\",\n \"ownerId\": \"<string>\",\n \"description\": \"Number of unique users who performed any action in the last 24 hours\",\n \"unit\": \"users\",\n \"type\": \"custom\",\n \"targetValue\": 100,\n \"targetDirection\": \"up\",\n \"currentValue\": 150,\n \"previousValue\": 140,\n \"periodType\": \"calendar\",\n \"periodValue\": \"month\",\n \"timeseries\": [\n {\n \"date\": \"2023-11-07T05:31:56Z\",\n \"value\": 85\n }\n ],\n \"relatedOutcomes\": [\n \"<unknown>\"\n ],\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"outcomeIds\": [\n \"7b9e5d2c-f314-48a9-be56-9843a2f6c019\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "7b9e5d2c-f314-48a9-be56-9843a2f6c019",
"title": "Daily Active Users",
"ownerId": "user_123456789",
"createdAt": "2023-01-01T00:00:00.000Z",
"updatedAt": "2023-01-01T00:00:00.000Z",
"description": "Number of unique users who performed any action in the last 24 hours",
"unit": "users",
"type": "custom",
"targetValue": 100,
"targetDirection": "up",
"currentValue": 150,
"previousValue": 140,
"periodType": "calendar",
"periodValue": "month",
"timeseries": [
{
"date": "2023-11-07T05:31:56Z",
"value": 85
}
],
"relatedOutcomes": [
"<unknown>"
]
}
}{
"error": {
"code": "INVALID_REQUEST",
"description": "One or more fields are invalid",
"fields": [
"title",
"description"
],
"validationErrors": {
"invalidFields": {
"title": {
"type": "too_small",
"message": "Title must be at least 3 characters long",
"path": [
"title"
]
},
"deadline": {
"type": "invalid_date",
"message": "Deadline must be a valid date in the future",
"path": [
"deadline"
]
}
}
}
}
}{
"error": {
"code": "UNAUTHORISED_ERROR",
"description": "User is unauthenticated"
}
}{
"error": {
"code": "UNAUTHORISED_ERROR",
"description": "User is unauthorised"
}
}{
"error": {
"code": "INTERNAL_SERVER_ERROR",
"description": "An unexpected error occurred on the server"
}
}Create a new metric
Creates a new metric.
curl --request POST \
--url https://api.meetsquad.ai/organisations/{orgId}/workspaces/{workspaceId}/metrics \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"title": "Daily Active Users",
"ownerId": "<string>",
"description": "Number of unique users who performed any action in the last 24 hours",
"unit": "users",
"type": "custom",
"targetValue": 100,
"targetDirection": "up",
"currentValue": 150,
"previousValue": 140,
"periodType": "calendar",
"periodValue": "month",
"timeseries": [
{
"date": "2023-11-07T05:31:56Z",
"value": 85
}
],
"relatedOutcomes": [
"<unknown>"
],
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"outcomeIds": [
"7b9e5d2c-f314-48a9-be56-9843a2f6c019"
]
}
'import requests
url = "https://api.meetsquad.ai/organisations/{orgId}/workspaces/{workspaceId}/metrics"
payload = {
"title": "Daily Active Users",
"ownerId": "<string>",
"description": "Number of unique users who performed any action in the last 24 hours",
"unit": "users",
"type": "custom",
"targetValue": 100,
"targetDirection": "up",
"currentValue": 150,
"previousValue": 140,
"periodType": "calendar",
"periodValue": "month",
"timeseries": [
{
"date": "2023-11-07T05:31:56Z",
"value": 85
}
],
"relatedOutcomes": ["<unknown>"],
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"outcomeIds": ["7b9e5d2c-f314-48a9-be56-9843a2f6c019"]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
title: 'Daily Active Users',
ownerId: '<string>',
description: 'Number of unique users who performed any action in the last 24 hours',
unit: 'users',
type: 'custom',
targetValue: 100,
targetDirection: 'up',
currentValue: 150,
previousValue: 140,
periodType: 'calendar',
periodValue: 'month',
timeseries: [{date: '2023-11-07T05:31:56Z', value: 85}],
relatedOutcomes: ['<unknown>'],
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
outcomeIds: ['7b9e5d2c-f314-48a9-be56-9843a2f6c019']
})
};
fetch('https://api.meetsquad.ai/organisations/{orgId}/workspaces/{workspaceId}/metrics', 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://api.meetsquad.ai/organisations/{orgId}/workspaces/{workspaceId}/metrics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'title' => 'Daily Active Users',
'ownerId' => '<string>',
'description' => 'Number of unique users who performed any action in the last 24 hours',
'unit' => 'users',
'type' => 'custom',
'targetValue' => 100,
'targetDirection' => 'up',
'currentValue' => 150,
'previousValue' => 140,
'periodType' => 'calendar',
'periodValue' => 'month',
'timeseries' => [
[
'date' => '2023-11-07T05:31:56Z',
'value' => 85
]
],
'relatedOutcomes' => [
'<unknown>'
],
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'outcomeIds' => [
'7b9e5d2c-f314-48a9-be56-9843a2f6c019'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.meetsquad.ai/organisations/{orgId}/workspaces/{workspaceId}/metrics"
payload := strings.NewReader("{\n \"title\": \"Daily Active Users\",\n \"ownerId\": \"<string>\",\n \"description\": \"Number of unique users who performed any action in the last 24 hours\",\n \"unit\": \"users\",\n \"type\": \"custom\",\n \"targetValue\": 100,\n \"targetDirection\": \"up\",\n \"currentValue\": 150,\n \"previousValue\": 140,\n \"periodType\": \"calendar\",\n \"periodValue\": \"month\",\n \"timeseries\": [\n {\n \"date\": \"2023-11-07T05:31:56Z\",\n \"value\": 85\n }\n ],\n \"relatedOutcomes\": [\n \"<unknown>\"\n ],\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"outcomeIds\": [\n \"7b9e5d2c-f314-48a9-be56-9843a2f6c019\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.meetsquad.ai/organisations/{orgId}/workspaces/{workspaceId}/metrics")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"title\": \"Daily Active Users\",\n \"ownerId\": \"<string>\",\n \"description\": \"Number of unique users who performed any action in the last 24 hours\",\n \"unit\": \"users\",\n \"type\": \"custom\",\n \"targetValue\": 100,\n \"targetDirection\": \"up\",\n \"currentValue\": 150,\n \"previousValue\": 140,\n \"periodType\": \"calendar\",\n \"periodValue\": \"month\",\n \"timeseries\": [\n {\n \"date\": \"2023-11-07T05:31:56Z\",\n \"value\": 85\n }\n ],\n \"relatedOutcomes\": [\n \"<unknown>\"\n ],\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"outcomeIds\": [\n \"7b9e5d2c-f314-48a9-be56-9843a2f6c019\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.meetsquad.ai/organisations/{orgId}/workspaces/{workspaceId}/metrics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"title\": \"Daily Active Users\",\n \"ownerId\": \"<string>\",\n \"description\": \"Number of unique users who performed any action in the last 24 hours\",\n \"unit\": \"users\",\n \"type\": \"custom\",\n \"targetValue\": 100,\n \"targetDirection\": \"up\",\n \"currentValue\": 150,\n \"previousValue\": 140,\n \"periodType\": \"calendar\",\n \"periodValue\": \"month\",\n \"timeseries\": [\n {\n \"date\": \"2023-11-07T05:31:56Z\",\n \"value\": 85\n }\n ],\n \"relatedOutcomes\": [\n \"<unknown>\"\n ],\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"outcomeIds\": [\n \"7b9e5d2c-f314-48a9-be56-9843a2f6c019\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "7b9e5d2c-f314-48a9-be56-9843a2f6c019",
"title": "Daily Active Users",
"ownerId": "user_123456789",
"createdAt": "2023-01-01T00:00:00.000Z",
"updatedAt": "2023-01-01T00:00:00.000Z",
"description": "Number of unique users who performed any action in the last 24 hours",
"unit": "users",
"type": "custom",
"targetValue": 100,
"targetDirection": "up",
"currentValue": 150,
"previousValue": 140,
"periodType": "calendar",
"periodValue": "month",
"timeseries": [
{
"date": "2023-11-07T05:31:56Z",
"value": 85
}
],
"relatedOutcomes": [
"<unknown>"
]
}
}{
"error": {
"code": "INVALID_REQUEST",
"description": "One or more fields are invalid",
"fields": [
"title",
"description"
],
"validationErrors": {
"invalidFields": {
"title": {
"type": "too_small",
"message": "Title must be at least 3 characters long",
"path": [
"title"
]
},
"deadline": {
"type": "invalid_date",
"message": "Deadline must be a valid date in the future",
"path": [
"deadline"
]
}
}
}
}
}{
"error": {
"code": "UNAUTHORISED_ERROR",
"description": "User is unauthenticated"
}
}{
"error": {
"code": "UNAUTHORISED_ERROR",
"description": "User is unauthorised"
}
}{
"error": {
"code": "INTERNAL_SERVER_ERROR",
"description": "An unexpected error occurred on the server"
}
}Authorizations
JWT authentication for organization-scoped endpoints.
Body
Request schema for creating a metric
Display name for the metric
"Daily Active Users"
Detailed description of the metric
"Number of unique users who performed any action in the last 24 hours"
Unit of measurement for the metric
"users"
Category/type of the metric
engagement, conversion, revenue, nps, csat, ces, ratio, custom Comparison operator for the target
greater_than, less_than, equal_to Target value to achieve
100
Direction of improvement (up = higher is better, down = lower is better)
up, down Current value of the metric
150
Previous value of the metric for comparison
140
Type of period for metric comparison
rolling, calendar "calendar"
Specific period value for metric comparison
day, week, month, quarter, year, 7-day, 30-day, 90-day "month"
Historical values for trend analysis
Show child attributes
Show child attributes
Related outcomes that use this metric
^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$Array of outcome IDs to associate with this metric
["7b9e5d2c-f314-48a9-be56-9843a2f6c019"]
Response
Success
Response containing a single metric
Metric data representing a measurable KPI result
Show child attributes
Show child attributes