Skip to main content

Get usage records

The consumption on a usage subscription is stored in usage records, a record is created per cycle. This allows you to see the entire usage history of the subscription as well as the current cycles consumption.

All usage records

Retrieve all usage records for a grantee. The response uses cursor pagination.

import { Salable } from '@salable/node-sdk';

const salable = new Salable('your-salable-api-key', 'v2');
const records = await salable.usage.getAllUsageRecords({
granteeId: 'grantee-id'
});

Current usage record

Retrieve the current usage for a grantee on a specific plan.

import { Salable } from '@salable/node-sdk';

const salable = new Salable('your-salable-api-key', 'v2');
const currentUsage = await api.usage.getCurrentUsageRecord({
granteeId: 'grantee-id',
planUuid: 'usage-plan-uuid'
});