Create a custom org-scoped metric
curl --request POST \
--url https://app.solya.app/api/intelligence-layer/metrics \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"body": {
"aggregation": {
"column": "quantity",
"function": "SUM"
},
"kind": "aggregation",
"source": {
"table": "gold.fact_sales_lines"
}
},
"category": "SALES",
"description": "Sum of sold quantities across all sales lines.",
"displayName": "Total Sold Quantity",
"grain": [
"shop_id",
"variant_id"
],
"isConfigurable": false,
"metricName": "total_sold_quantity",
"outputColumn": "total_sold_quantity",
"outputType": "BIGINT"
}
'import requests
url = "https://app.solya.app/api/intelligence-layer/metrics"
payload = {
"body": {
"aggregation": {
"column": "quantity",
"function": "SUM"
},
"kind": "aggregation",
"source": { "table": "gold.fact_sales_lines" }
},
"category": "SALES",
"description": "Sum of sold quantities across all sales lines.",
"displayName": "Total Sold Quantity",
"grain": ["shop_id", "variant_id"],
"isConfigurable": False,
"metricName": "total_sold_quantity",
"outputColumn": "total_sold_quantity",
"outputType": "BIGINT"
}
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({
body: JSON.stringify({
aggregation: {column: 'quantity', function: 'SUM'},
kind: 'aggregation',
source: {table: 'gold.fact_sales_lines'}
}),
category: 'SALES',
description: 'Sum of sold quantities across all sales lines.',
displayName: 'Total Sold Quantity',
grain: ['shop_id', 'variant_id'],
isConfigurable: false,
metricName: 'total_sold_quantity',
outputColumn: 'total_sold_quantity',
outputType: 'BIGINT'
})
};
fetch('https://app.solya.app/api/intelligence-layer/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://app.solya.app/api/intelligence-layer/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([
'body' => [
'aggregation' => [
'column' => 'quantity',
'function' => 'SUM'
],
'kind' => 'aggregation',
'source' => [
'table' => 'gold.fact_sales_lines'
]
],
'category' => 'SALES',
'description' => 'Sum of sold quantities across all sales lines.',
'displayName' => 'Total Sold Quantity',
'grain' => [
'shop_id',
'variant_id'
],
'isConfigurable' => false,
'metricName' => 'total_sold_quantity',
'outputColumn' => 'total_sold_quantity',
'outputType' => 'BIGINT'
]),
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://app.solya.app/api/intelligence-layer/metrics"
payload := strings.NewReader("{\n \"body\": {\n \"aggregation\": {\n \"column\": \"quantity\",\n \"function\": \"SUM\"\n },\n \"kind\": \"aggregation\",\n \"source\": {\n \"table\": \"gold.fact_sales_lines\"\n }\n },\n \"category\": \"SALES\",\n \"description\": \"Sum of sold quantities across all sales lines.\",\n \"displayName\": \"Total Sold Quantity\",\n \"grain\": [\n \"shop_id\",\n \"variant_id\"\n ],\n \"isConfigurable\": false,\n \"metricName\": \"total_sold_quantity\",\n \"outputColumn\": \"total_sold_quantity\",\n \"outputType\": \"BIGINT\"\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://app.solya.app/api/intelligence-layer/metrics")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"body\": {\n \"aggregation\": {\n \"column\": \"quantity\",\n \"function\": \"SUM\"\n },\n \"kind\": \"aggregation\",\n \"source\": {\n \"table\": \"gold.fact_sales_lines\"\n }\n },\n \"category\": \"SALES\",\n \"description\": \"Sum of sold quantities across all sales lines.\",\n \"displayName\": \"Total Sold Quantity\",\n \"grain\": [\n \"shop_id\",\n \"variant_id\"\n ],\n \"isConfigurable\": false,\n \"metricName\": \"total_sold_quantity\",\n \"outputColumn\": \"total_sold_quantity\",\n \"outputType\": \"BIGINT\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.solya.app/api/intelligence-layer/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 \"body\": {\n \"aggregation\": {\n \"column\": \"quantity\",\n \"function\": \"SUM\"\n },\n \"kind\": \"aggregation\",\n \"source\": {\n \"table\": \"gold.fact_sales_lines\"\n }\n },\n \"category\": \"SALES\",\n \"description\": \"Sum of sold quantities across all sales lines.\",\n \"displayName\": \"Total Sold Quantity\",\n \"grain\": [\n \"shop_id\",\n \"variant_id\"\n ],\n \"isConfigurable\": false,\n \"metricName\": \"total_sold_quantity\",\n \"outputColumn\": \"total_sold_quantity\",\n \"outputType\": \"BIGINT\"\n}"
response = http.request(request)
puts response.read_body{
"body": {
"aggregation": {
"column": "quantity",
"function": "SUM"
},
"kind": "aggregation",
"source": {
"table": "gold.fact_sales_lines"
}
},
"category": "SALES",
"configSchema": null,
"createdAt": "2026-06-04T10:00:00.000Z",
"defaultConfig": null,
"description": "Sum of sold quantities across all sales lines.",
"displayName": "Total Sold Quantity",
"enabled": true,
"grain": [
"shop_id",
"variant_id"
],
"id": "metric-uuid-new-1",
"isConfigurable": false,
"metricName": "total_sold_quantity",
"organizationId": "org-uuid-123",
"outputColumn": "total_sold_quantity",
"outputType": "BIGINT",
"parameters": {},
"scope": "ORG",
"subcategory": null,
"updatedAt": null,
"version": 2
}Metrics
Create a custom org-scoped metric
Creates a new ORG-scoped metric for the caller’s organization. The body field must be a valid discriminated-union metric definition (kind: precomputed_column, aggregation, time_windowed_aggregation, composite, or unsupported). The metricVersion is set automatically to the current spec version. Requires intelligenceLayer.configure permission.
POST
/
api
/
intelligence-layer
/
metrics
Create a custom org-scoped metric
curl --request POST \
--url https://app.solya.app/api/intelligence-layer/metrics \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"body": {
"aggregation": {
"column": "quantity",
"function": "SUM"
},
"kind": "aggregation",
"source": {
"table": "gold.fact_sales_lines"
}
},
"category": "SALES",
"description": "Sum of sold quantities across all sales lines.",
"displayName": "Total Sold Quantity",
"grain": [
"shop_id",
"variant_id"
],
"isConfigurable": false,
"metricName": "total_sold_quantity",
"outputColumn": "total_sold_quantity",
"outputType": "BIGINT"
}
'import requests
url = "https://app.solya.app/api/intelligence-layer/metrics"
payload = {
"body": {
"aggregation": {
"column": "quantity",
"function": "SUM"
},
"kind": "aggregation",
"source": { "table": "gold.fact_sales_lines" }
},
"category": "SALES",
"description": "Sum of sold quantities across all sales lines.",
"displayName": "Total Sold Quantity",
"grain": ["shop_id", "variant_id"],
"isConfigurable": False,
"metricName": "total_sold_quantity",
"outputColumn": "total_sold_quantity",
"outputType": "BIGINT"
}
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({
body: JSON.stringify({
aggregation: {column: 'quantity', function: 'SUM'},
kind: 'aggregation',
source: {table: 'gold.fact_sales_lines'}
}),
category: 'SALES',
description: 'Sum of sold quantities across all sales lines.',
displayName: 'Total Sold Quantity',
grain: ['shop_id', 'variant_id'],
isConfigurable: false,
metricName: 'total_sold_quantity',
outputColumn: 'total_sold_quantity',
outputType: 'BIGINT'
})
};
fetch('https://app.solya.app/api/intelligence-layer/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://app.solya.app/api/intelligence-layer/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([
'body' => [
'aggregation' => [
'column' => 'quantity',
'function' => 'SUM'
],
'kind' => 'aggregation',
'source' => [
'table' => 'gold.fact_sales_lines'
]
],
'category' => 'SALES',
'description' => 'Sum of sold quantities across all sales lines.',
'displayName' => 'Total Sold Quantity',
'grain' => [
'shop_id',
'variant_id'
],
'isConfigurable' => false,
'metricName' => 'total_sold_quantity',
'outputColumn' => 'total_sold_quantity',
'outputType' => 'BIGINT'
]),
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://app.solya.app/api/intelligence-layer/metrics"
payload := strings.NewReader("{\n \"body\": {\n \"aggregation\": {\n \"column\": \"quantity\",\n \"function\": \"SUM\"\n },\n \"kind\": \"aggregation\",\n \"source\": {\n \"table\": \"gold.fact_sales_lines\"\n }\n },\n \"category\": \"SALES\",\n \"description\": \"Sum of sold quantities across all sales lines.\",\n \"displayName\": \"Total Sold Quantity\",\n \"grain\": [\n \"shop_id\",\n \"variant_id\"\n ],\n \"isConfigurable\": false,\n \"metricName\": \"total_sold_quantity\",\n \"outputColumn\": \"total_sold_quantity\",\n \"outputType\": \"BIGINT\"\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://app.solya.app/api/intelligence-layer/metrics")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"body\": {\n \"aggregation\": {\n \"column\": \"quantity\",\n \"function\": \"SUM\"\n },\n \"kind\": \"aggregation\",\n \"source\": {\n \"table\": \"gold.fact_sales_lines\"\n }\n },\n \"category\": \"SALES\",\n \"description\": \"Sum of sold quantities across all sales lines.\",\n \"displayName\": \"Total Sold Quantity\",\n \"grain\": [\n \"shop_id\",\n \"variant_id\"\n ],\n \"isConfigurable\": false,\n \"metricName\": \"total_sold_quantity\",\n \"outputColumn\": \"total_sold_quantity\",\n \"outputType\": \"BIGINT\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.solya.app/api/intelligence-layer/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 \"body\": {\n \"aggregation\": {\n \"column\": \"quantity\",\n \"function\": \"SUM\"\n },\n \"kind\": \"aggregation\",\n \"source\": {\n \"table\": \"gold.fact_sales_lines\"\n }\n },\n \"category\": \"SALES\",\n \"description\": \"Sum of sold quantities across all sales lines.\",\n \"displayName\": \"Total Sold Quantity\",\n \"grain\": [\n \"shop_id\",\n \"variant_id\"\n ],\n \"isConfigurable\": false,\n \"metricName\": \"total_sold_quantity\",\n \"outputColumn\": \"total_sold_quantity\",\n \"outputType\": \"BIGINT\"\n}"
response = http.request(request)
puts response.read_body{
"body": {
"aggregation": {
"column": "quantity",
"function": "SUM"
},
"kind": "aggregation",
"source": {
"table": "gold.fact_sales_lines"
}
},
"category": "SALES",
"configSchema": null,
"createdAt": "2026-06-04T10:00:00.000Z",
"defaultConfig": null,
"description": "Sum of sold quantities across all sales lines.",
"displayName": "Total Sold Quantity",
"enabled": true,
"grain": [
"shop_id",
"variant_id"
],
"id": "metric-uuid-new-1",
"isConfigurable": false,
"metricName": "total_sold_quantity",
"organizationId": "org-uuid-123",
"outputColumn": "total_sold_quantity",
"outputType": "BIGINT",
"parameters": {},
"scope": "ORG",
"subcategory": null,
"updatedAt": null,
"version": 2
}Authorizations
User session token issued by NextAuth. For human users accessing Solya via the web application.
Body
application/json
- Option 1
- Option 2
- Option 3
- Option 4
- Option 5
Show child attributes
Show child attributes
Minimum string length:
1Required string length:
1 - 255Minimum array length:
1Minimum string length:
1Required string length:
1 - 255Required string length:
1 - 255Show child attributes
Show child attributes
⌘I

