const { result, error } = await unprice.customers.getUsage("cus_1234567890");

if (error) {
  // handle potential network or bad request error
  // a link to our docs will be in the `error.docs` field
  console.error(error.message);
  return;
}

console.log(result);
{
  "usage": [
    {
      "featureSlug": "feature_1",
      "used": 100,
      "limit": 1000,
      "resetAt": 1681492000
    }
  ]
}
const { result, error } = await unprice.customers.getUsage("cus_1234567890");

if (error) {
  // handle potential network or bad request error
  // a link to our docs will be in the `error.docs` field
  console.error(error.message);
  return;
}

console.log(result);
{
  "usage": [
    {
      "featureSlug": "feature_1",
      "used": 100,
      "limit": 1000,
      "resetAt": 1681492000
    }
  ]
}

Request

customerId
string
required

The ID of the customer to get usage for

Response

usage
array
required

Array of usage information for each feature

usage[].featureSlug
string
required

The slug of the feature

usage[].used
number
required

The amount of usage consumed

usage[].limit
number
required

The usage limit for the feature

usage[].resetAt
number
required

The timestamp when the usage will reset