Skip to content

Profitability API

All endpoints require authentication and reporting view permission. Cost rates are derived from the Productive integration’s budget report (org-wide average cost per hour).

GET /api/profitability

Returns profitability data broken down by project and aggregated by client.

Query parameters:

ParamTypeDescription
date_fromstringStart date (YYYY-MM-DD, default: first day of current month)
date_tostringEnd date (YYYY-MM-DD, default: last day of current month)
squadstringFilter by squad name
client_idstringFilter by client company ID

Response:

{
"summary": {
"total_revenue",
"total_cost",
"gross_margin",
"margin_percent",
"avg_cost_per_hour"
},
"projects": [...],
"clients": [...],
"date_from",
"date_to"
}

Revenue is calculated from invoices with status sent or paid, linked via budgets to projects. Cost is calculated as approved time entry hours multiplied by the org-wide average cost per hour from Productive.

Each project includes:

FieldTypeDescription
project_idstringProject ID
project_namestringProject name
client_idstringCompany ID
client_namestringCompany name
squadstringSquad name
revenuenumberTotal invoiced revenue
costnumberEstimated cost (hours x avg rate)
gross_marginnumberRevenue minus cost
margin_percentnumberMargin as percentage of revenue
has_incomplete_databooleanTrue if revenue or hours are zero

Each client aggregate includes client_id, client_name, revenue, cost, gross_margin, and margin_percent.

GET /api/profitability/trend

Returns a 12-month rolling trend of monthly revenue, cost, and margin.

Query parameters:

ParamTypeDescription
squadstringFilter by squad name
client_idstringFilter by client company ID

Response: { months }

Each month includes:

FieldTypeDescription
monthstringPeriod key (YYYY-MM)
labelstringHuman-readable label (e.g. “Apr 26”)
revenuenumberMonthly revenue
costnumberMonthly cost
gross_marginnumberRevenue minus cost
margin_percentnumberMargin percentage