GET
/
subscriptions
/
{subscription_id}
/
usage-history
JavaScript
import DodoPayments from 'dodopayments';

const client = new DodoPayments({
  bearerToken: 'My Bearer Token',
});

// Automatically fetches more pages as needed.
for await (const subscriptionRetrieveUsageHistoryResponse of client.subscriptions.retrieveUsageHistory(
  'subscription_id',
)) {
  console.log(subscriptionRetrieveUsageHistoryResponse.end_date);
}
{
  "items": [
    {
      "end_date": "2023-11-07T05:31:56Z",
      "meters": [
        {
          "chargeable_units": "<string>",
          "consumed_units": "<string>",
          "currency": "AED",
          "free_threshold": 123,
          "id": "<string>",
          "name": "<string>",
          "price_per_unit": "<string>",
          "total_price": 123
        }
      ],
      "start_date": "2023-11-07T05:31:56Z"
    }
  ]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

subscription_id
string
required

Unique subscription identifier

Query Parameters

start_date
string<date-time> | null

Filter by start date (inclusive)

end_date
string<date-time> | null

Filter by end date (inclusive)

meter_id
string | null

Filter by specific meter ID

page_size
integer | null

Page size (default: 10, max: 100)

Required range: x >= 0
page_number
integer | null

Page number (default: 0)

Required range: x >= 0

Response

200
application/json

Usage history retrieved successfully

The response is of type object.