Skip to main content

API - Get a tenants usage by month

Thread solved
Posts: 2
Comments: 3

Hi all,

is it possible to get the usage of a tenant by month?

The API endpoint /tenants/<id>/usages just show the latest month. In the json respone I can see a "range_start" parameter. So is there any way to get the usage of a specific month? 

We would like to get this information to automate the billing process for our customers.

Thank you,


0 Users found this helpful
Acronis engineer
Posts: 0
Comments: 84

Hello Daniel,

Thank you for your post.

GET /tenants/{tenant_id}/usages and GET /tenants/usages doesn't provide range parameters for setting a specific period. They provide common usage metrics for the current billing period only, for a tenant or batch of tenants.

For billing I would recommend that you use reporting, and specifically usage reports with SKU for billing purposes. Below is a base flow defining usages reports with SKU for billing purposes with detailed API calls descriptions including parameters and JSON fields.

To create a Usage Report with SKU for Billing Purposes you need to use POST /reports call with the "schedule" object with field "type" set to "once" and run a report with "result_action" field set to the value "save". For monthly scheduled reports, only 2 file formats are available: html and csv, which are less suitable for automatic processing. As a bill is generated monthly at the last day of a month, you can use value "usage_summary" for field "kind" and provide "period" object with "start" and "end" fields filed with the first day and the last day of a month planned to process and call that report at the first or the second day of the next month. To add SKU to the report the "show_skus" parameter set to "true" should be added. To remove zero valued SKU usage use the "hide_zero_usage" parameter set to "true". As a value for the "tenant_id" field, it is usually used the value of your root tenant’s 'uuid' with the "level" field specifying the needed level of details for your purposes and business processes. For a distributor, in most cases, "direct_partners" value might be used. As a result of this call, a stored report is created with SKU and zero usage for SKU excluded.

Example Body: { "parameters": { "kind": "usage_summary", "level": "direct_partners", "tenant_id": "{{my_tenant_id}}", "formats": [ "csv_v2_0" ], "show_skus": true, "hide_zero_usage": true }, "period": { "start": "2021-08-01", "end": "2021-08-31" }, "schedule": { "type": "once" }, "result_action": "save" }

Example Response: { "generation_date": "2021-10-25", "id": "{{report_id}}", "version": 1, "recipients": [], "result_action": "save", "schedule": { "enabled": true, "type": "once" }, "parameters": { "hide_zero_usage": true, "formats": [ "csv_v2_0" ], "level": "direct_partners", "kind": "usage_summary", "tenant_id": "{{my_tenant_id}}", "show_skus": true, "period": { "end": "2021-10-24", "start": "2021-10-01" } } }

Direct example in our public Postman collections: Create a Billing Usage Report

This report can be used as a main base for the billing purposes. It requires only to add name for SKUs and remove lines with no-SKU.

All about Usage and Reporting, all objects, parameters, fields, kinds, range and levels of reports are described at: Usage and Reporting APIv2

Thank you, I hope it will be helpful.