get usage report.md
Get usage report
Management API · Reports
POST https://app.mk.io/api/v1/organization/reports/usage
Returns meter-level usage aggregated by set granularity over the specified date range.
- Can be filtered by
projectNames,paymentMethodIdsormeterNames. - Maximum date range depends on granularity: 31 days (
hour), 1 year (day), unlimited (week,month,year). - Day boundaries use UTC;
startDateis inclusive andendDateis exclusive (previously also inclusive). - To get a monthly report for January, use
startDate=2026-01-01andendDate=2026-02-01. - The response include
dateanddate_processedfields.dateis the time when the usage happened, whiledate_processedis when the usage was ingested into our system and processed for billing purposes. - Set
filterOnReportedDate=trueto filter bydate_processedinstead ofdate. This might include usage that occurred before thestartDateif it was processed during the date range. - Set
format=csvanddownload=trueto receive a file download.
RBAC Capability Required: core.customer.get
Authentication
Authorizationheader — Bearer authentication of the formBearer <token>.
Request body
Content type: application/json
download· boolean · Optional · Defaults to false — When true, sets response headers to prompt a browser file download.endDate· string · Required · format: date — End date of the usage report (exclusive). This use to be inclusive. To get a full month of usage, set both startDate and endDate to the first of the month. Maximum range depends on granularity: 31 days for 'hour', 1 year for 'day', unlimited for 'week', 'month', or 'year'.filterOnReportedDate· boolean · Optional · Defaults to false — When true, filters usage by report_time (when the usage was charged) rather than sample_time (when it occurred). Useful for reconciling against invoice dates. Defaults to false.format· enum · Optional · Defaults to json — Response format. Either 'json' or 'csv'. Defaults to 'json'.- Allowed values:
json,csv
- Allowed values:
granularity· enum · Optional · Defaults to day — Time bucket for aggregation. Defaults to 'day'.- Allowed values:
year,month,week,day,hour
- Allowed values:
groupBy· list of strings · Optional — Fields to group results by. Only 'meter' is currently valid. Defaults to ['meter'].- Array items (string):
meterNames· list of strings · Optional — Filter results to the specified meter names.- Array items (string):
paymentMethodIds· list of strings · Optional — Filter results to the specified payment method IDs. Mutually exclusive with projectNames.- Array items (string):
projectNames· list of strings · Optional — Filter results to the specified project names. Mutually exclusive with paymentMethodIds.- Array items (string):
startDate· string · Required · format: date — Start date of the usage report (inclusive).
Example request
curl -X POST "https://app.mk.io/api/v1/organization/reports/usage" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"download": true,
"endDate": "2025-04-01",
"filterOnReportedDate": true,
"format": "csv",
"granularity": "hour",
"paymentMethodIds": [
"a1b2c3d4-e5f6-7890-abcd-ef1234567890"
],
"startDate": "2025-03-01"
}'
Responses
200 — OK
supplemental· object · Required — Metadata pertaining to the query.download· boolean · Required — Whether browser was indicated to download fileend· string · Required · format: date — The end date of the query.filters· object · Required — The filters applied to the query.meterNames· list of strings · Required — Meter names the results were filtered to.- Array items (string):
paymentMethodIds· list of strings · Required — Payment method IDs the results were filtered to.- Array items (string):
projectNames· list of strings · Required — Project names the results were filtered to.- Array items (string):
format· string · Required — The output format. Either csv or json.granularity· string · Required — The time bucket used for aggregation.groupBy· list of strings · Required — The list of fields that the results are grouped by.- Array items (string):
records· integer · Required — The number of result records returned.start· string · Required · format: date — The start date of the query.
value· list of objects · Required — The usage data per day per meter- Array items (object):
cost· string · Required — Monetary value of usage for this record, in the currency specified by the currency field. How this is charged depends on the entitlement type: for a license entitlement the amount is fully covered and nothing is billed; for cash, quantity, or pre-commitment entitlements this amount is deducted from the entitlement balance; with no entitlement the amount is billed directly.currency· string · Required — The currency of the cost field.date· string · Required · format: date-time — The date and time of this usage record. Truncated to the granularity of the query (e.g. if granularity is 'day' then time will be 00:00:00).dateProcessed· string or null · Optional · format: date-time — The report_time truncated to the requested granularity. Null for usage that has not yet been charged. Comparing against date (sample_time) reveals late-reported data.entitlement· string or null · Optional · format: uuid — The ID of the entitlement applied to this usage. Can be joined against the /entitlements endpoint.entitlementType· string or null · Optional — The type of entitlement applied to this usage, if any.family· string · Optional — Product family this meter belongs to.meterName· string · Required — The meter name.meterSku· string or null · Optional — The SaaS SKU identifier for this meter.paymentMethod· string · Optional · format: uuid — The ID of the payment method associated with this usage.paymentMethodName· string or null · Optional — The display name of the payment method associated with this usage.price· double · Optional — Per-unit price for this record (cost / quantity).project· string · Optional — The name of the project this usage belongs to.quantity· double · Required — Total units accrued for this record.solution· string · Optional — Solution within the product family this meter belongs to.unit· string or null · Optional — The unit that this meter is reported in, e.g. 'gigabytes' or 'minutes'.
- Array items (object):
Example:
{
"supplemental": {
"download": true,
"end": "2024-01-01",
"filters": {
"meterNames": [
"string"
],
"paymentMethodIds": [
"00000000-0000-0000-0000-000000000000"
],
"projectNames": [
"string"
]
},
"format": "string",
"granularity": "string",
"groupBy": [
"string"
],
"records": 0,
"start": "2024-01-01"
},
"value": [
{
"cost": "string",
"currency": "string",
"date": "2024-01-01T00:00:00Z",
"dateProcessed": "2024-01-01T00:00:00Z",
"entitlement": "00000000-0000-0000-0000-000000000000",
"entitlementType": "string",
"family": "string",
"meterName": "string",
"meterSku": "string",
"paymentMethod": "00000000-0000-0000-0000-000000000000",
"paymentMethodName": "string",
"price": 0,
"project": "string",
"quantity": 0,
"solution": "string",
"unit": "string"
}
]
}
400 — Bad Request
error· object · Required — Pertinent information about the errorcode· string · Required — The error code.detail· string · Required — The error message.extraDetail· map from strings to any · Optional — Extra information regarding this error.[any key]· any — map of additional properties
ref· string · Required — A reference to the request that caused the error.status· integer · Required — The HTTP status code
Example:
{
"error": {
"code": "string",
"detail": "string",
"extraDetail": {
"key": null
}
},
"ref": "string",
"status": 0
}
401 — Unauthorized
Example:
{
"error": {
"code": "string",
"detail": "string",
"extraDetail": {
"key": null
}
},
"ref": "string",
"status": 0
}
403 — Forbidden
Example:
{
"error": {
"code": "string",
"detail": "string",
"extraDetail": {
"key": null
}
},
"ref": "string",
"status": 0
}
404 — Not Found
Example:
{
"error": {
"code": "string",
"detail": "string",
"extraDetail": {
"key": null
}
},
"ref": "string",
"status": 0
}
409 — Conflict
Example:
{
"error": {
"code": "string",
"detail": "string",
"extraDetail": {
"key": null
}
},
"ref": "string",
"status": 0
}
429 — Too Many Requests
Example:
{
"error": {
"code": "string",
"detail": "string",
"extraDetail": {
"key": null
}
},
"ref": "string",
"status": 0
}
500 — Internal Server Error
Example:
{
"error": {
"code": "string",
"detail": "string",
"extraDetail": {
"key": null
}
},
"ref": "string",
"status": 0
}
Source spec: management-api · operationId: [post]_/api/v1/organization/reports/usage