Skip to main content
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"
}
'
{
  "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

Authorization
string
header
required

User session token issued by NextAuth. For human users accessing Solya via the web application.

Body

application/json
body
object
required
category
string
required
Minimum string length: 1
displayName
string
required
Required string length: 1 - 255
grain
string[]
required
Minimum array length: 1
Minimum string length: 1
metricName
string
required
Required string length: 1 - 255
outputColumn
string
required
Required string length: 1 - 255
configSchema
any[]
defaultConfig
object
description
string
isConfigurable
boolean
default:false
outputType
string
default:DOUBLE
subcategory
string

Response

Successful response

data
object
required
success
enum<boolean>
required
Available options:
true