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.
- Node SDK
- Fetch
- cURL
import { Salable } from '@salable/node-sdk';
const salable = new Salable('your-salable-api-key', 'v2');
const records = await salable.usage.getAllUsageRecords({
granteeId: 'grantee-id'
});
const response = await fetch(
'https://api.salable.app/usage?granteeId=grantee-id',
{
headers: {
version: 'v2',
'x-api-key': 'your-salable-api-key',
},
}
);
const records = await response.json();
curl
-XGET
-H 'x-api-key: your-salable-api-key'
-H 'version: v2'
'https://api.salable.app/usage?granteeId=grantee-id'
Current usage record
Retrieve the current usage for a grantee on a specific plan.
- Node SDK
- Fetch
- cURL
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'
});
const response = await fetch(
'https://api.salable.app/usage/current?granteeId=grantee-id&planUuid=usage-plan-uuid',
{
headers: {
version: 'v2',
'x-api-key': 'your-salable-api-key',
},
}
);
const currentUsage = await response.json();
curl
-XGET
-H 'x-api-key: your-salable-api-key'
-H 'version: v2'
'https://api.salable.app/usage/current?granteeId=grantee-id&planUuid=usage-plan-uuid'