Reporting Manager API · analytics
The margin over the last 7
GET /analytics/margin
The margin over the last 7, 30 or 90 days (period, 30d by default), read from the reporting star's order-line facts.
A line's cost of goods is known once the dispatch that fixes it has been folded, so the margin is taken over the costed lines only (costedProceedsCents against cogsCents, marginPercent to one place, null with nothing costed) and lines / costedLines say how much of the window that covers; proceedsCents is every line's, net of discounts and of tax. belowCost names up to five SKUs whose costed sales came in under their cost, the biggest loss first.
Access
Requires financials:read.
How scopes come from roles: Scopes and roles. Getting a token: Authentication and app tokens.
AI agent tool
Agents call this as reporting_get_margin (Reporting: Get margin), in the reporting toolset. It only reads.
Connecting an agent: AI agents.
Example
curl -X GET 'https://reporting.getmanifold.io/analytics/margin?period=7d' \
-H "Authorization: Bearer $MANIFOLD_TOKEN"const response = await fetch("https://reporting.getmanifold.io/analytics/margin?period=7d", {
method: "GET",
headers: { Authorization: `Bearer ${process.env.MANIFOLD_TOKEN}` },
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
const answer = await response.json();{
"period": {
"firstDay": "2026-10-14",
"lastDay": "2026-10-20"
},
"currency": "AUD",
"proceedsCents": 296100,
"costedProceedsCents": 281400,
"cogsCents": 168200,
"lines": 31,
"costedLines": 29,
"unconvertedLines": 0,
"marginPercent": 40.2,
"belowCost": [
{
"sku": "WIDGET-RED",
"name": "Red widget, 40mm",
"units": 3,
"proceedsCents": 2970,
"cogsCents": 3540
}
],
"asOf": [
{
"source": "inventory",
"tenants": 1,
"maxFoldedSequence": 128,
"lastRun": {
"at": "2026-10-20T08:59:58.000Z",
"outcome": "folded",
"folded": 3,
"skipped": 0,
"durationMs": 41
}
},
{
"source": "fulfillment",
"tenants": 1,
"maxFoldedSequence": 77,
"lastRun": {
"at": "2026-10-20T08:59:58.000Z",
"outcome": "empty",
"folded": 0,
"skipped": 0,
"durationMs": 6
}
}
]
}The panel writes this call in other languages. It does not send it: Manifold's APIs do not take calls from a web
page on another site, so run the call from your own code or terminal. The whole API as OpenAPI: reporting-manager.openapi.json. Base URL https://reporting.getmanifold.io.
Errors
Every refusal is a status and a JSON body whose _tag names it. A refused call changes nothing.
401
| Refusal | What it means | What to do |
|---|---|---|
Unauthorized reason | The token is missing, expired or not one Manifold issued. | Get a fresh token and send the call again. |
TokenAlreadyUsed tokenId | A single-use app token was already spent. | Mint a new token for this call. |
402
| Refusal | What it means | What to do |
|---|---|---|
SubscriptionRequired status | The organization's subscription has lapsed, so writes are refused. | An owner settles billing. Reads still work meanwhile. |
403
| Refusal | What it means | What to do |
|---|---|---|
TenantRequired userId | The token names no organization. | Choose the organization, then get a new token. |
ScopeRequired required | The token's roles do not grant the scope this call needs. | Ask an owner or admin for a role that grants it. |
409
| Refusal | What it means | What to do |
|---|---|---|
MirroredFromSource source | This area is fed by your source system until the organization goes live. | Make the change in the source system, or go live first. |
503
| Refusal | What it means | What to do |
|---|---|---|
RequestLogUnavailable tokenId, reason | The service could not record the request, so it did nothing. | Try again shortly. |
How refusals work everywhere: Errors.
Used in
- Read the dashboard and tidy it, step 5: The margin