Skip to main content
Version 7.0.0 introduces a terminology change: Product has been renamed to Meter throughout the SDK to better reflect its purpose in usage-based billing.
Database ID formats remain unchanged (still use prd_ and ps_ prefixes).

Breaking Changes

1. Forward Token Generation

The product_secret parameter has been renamed to meter_secret.
const token = lava.generateForwardToken({
  connection_secret: 'cs_xxx',
  product_secret: 'ps_xxx'
});

2. Request and Usage Queries

Query parameters have been renamed from product_id to meter_id.
const requests = await lava.requests.list({
  product_id: 'prd_xxx'
});

const usage = await lava.usage.retrieve({
  start: '2024-01-01',
  product_id: 'prd_xxx'
});

3. Creating Requests

The product_secret parameter has been renamed to meter_secret.
await lava.requests.create({
  request_id: 'req_xxx',
  connection_secret: 'cs_xxx',
  product_secret: 'ps_xxx',
  input_tokens: 100
});

4. Subscription Methods

Subscription methods have been restructured and now return paginated responses.
// Returns array
const configs = await lava.subscriptions.listConfigs();

5. Removed Methods

The following methods have been removed:
  • lava.checkoutSessions.list() - No replacement
  • lava.checkoutSessions.retrieve() - No replacement
  • reference_id parameter in lava.connections.list() - Filter client-side instead

New Features

Meters Resource

Access meter information directly:
const meters = await lava.meters.list({ cursor: 'xxx', limit: 10 });
const meter = await lava.meters.retrieve('prd_xxx');

Credit Bundles Resource

Access credit bundle configurations:
const bundles = await lava.creditBundles.list({
  subscription_config_id: 'sc_xxx'
});
const bundle = await lava.creditBundles.retrieve('cb_xxx');

Migration Steps

  1. Update package version: npm install @lavapayments/[email protected]
  2. Search and replace: Find all instances of product_secret and replace with meter_secret
  3. Update query parameters: Replace product_id with meter_id in request and usage queries
  4. Update subscription calls: Add pagination parameters to listConfigs() calls
  5. Remove deprecated methods: Replace checkoutSessions.list() and checkoutSessions.retrieve() calls
  6. Test thoroughly: Verify all integration points work with the new parameter names