Overview / Finance / Build a report from your own breakdown

Build a report from your own breakdown

post https://api.flactrum.com/v1/reports/run

The fixed categories answer fixed questions; this one answers yours. Pick up to two dimensions (branch, region, day, month, weekday, hour, product, category, channel, payment_method) and any metrics (orders, revenue, net_revenue, tax, basket, quantity, cost, profit, margin, discount, campaign_discount, refunded), then narrow with a period, region, branches or channels. The breakdown decides the data source: product and category read order lines, payment_method reads payment parts (a split payment lands on each method separately), everything else reads orders. A measure that cannot be figured for the chosen breakdown — ingredient cost per payment method, say — is left out of the columns and named in meta.dropped_metrics, never returned as a silent zero. Branch scope follows the key or the signed-in user; asking for a branch outside it returns nothing rather than an error. Panel equivalent: Report studio.

Required scope reports.read
Success status200

Request body

FieldTypeDescription
dimensions * array Row axis, in order. A third would make the table unreadable, so two is the limit. payment_method cannot be combined with another breakdown: one line cannot be split across two methods.
metrics * array —
range string —
from string With range=custom. Read in the brand timezone.
to string —
region string —
branches array —
channels array —
sort string A metric key. Defaults to the first metric.
direction string —

Examples

Recorded from the test suite — these are real requests and their real responses.

curl -X POST 'https://api.flactrum.com/v1/reports/run' \
  -H 'Authorization: Bearer flk_your_key:your_secret' \
  -H 'Content-Type: application/json' \
  -d '{
    "dimensions": [
        "branch"
    ],
    "metrics": [
        "orders",
        "revenue",
        "cost",
        "profit",
        "margin"
    ],
    "range": "today"
}'

HTTP 200 · application/json

{
    "data": {
        "columns": [
            {
                "key": "branch",
                "label": "Şube",
                "format": "text"
            },
            {
                "key": "orders",
                "label": "Sipariş",
                "format": "number"
            },
            {
                "key": "revenue",
                "label": "Ciro",
                "format": "money"
            },
            {
                "key": "cost",
                "label": "Hammadde maliyeti",
                "format": "money"
            },
            {
                "key": "profit",
                "label": "Brüt kâr",
                "format": "money"
            },
            {
                "key": "margin",
                "label": "Marj",
                "format": "percent"
            },
            {
                "key": "net_revenue",
                "label": "Matrah",
                "format": "money"
            }
        ],
        "rows": [
            {
                "branch": "Nişantaşı",
                "orders": 1,
                "revenue": 220,
                "cost": 60,
                "net_revenue": 200,
                "profit": 140,
                "margin": 70
            }
        ]
    },
    "meta": {
        "totals": {
            "orders": 1,
            "revenue": 220,
            "cost": 60,
            "profit": 140,
            "net_revenue": 200,
            "margin": 70
        },
        "mode": "order",
        "dropped_metrics": []
    }
}