License check
Check whether a grantee is licensed to perform actions in your system.
Features, capabilities, and plans that belong to your user are checkable.
- JavaScript
- Node.js
- cURL
import { getGrantee } from '@salable/js';
const { hasCapability } = await getGrantee({
apiKey: 'your-salable-api-key',
productUuid: 'your-products-uuid',
granteeId: 'your-grantees-id',
});
// Check for a capability
const isUserLicensedToPerformAction = hasCapability('acme-inc-whitelabelling');
// or a feature
const isUserLicensedToPerformAction = hasCapability('csv-export');
// or a plan
const isUserLicensedToPerformAction = hasCapability('pro');
import { Salable } from '@salable/node-sdk';
const salable = new Salable('your-salable-api-key');
const { capabilities } = await salable.licenses.check(
'your-product-uuid',
['your-grantees-id'],
3 // Optional: number of days grace period.
);
const isUserLicensedToPerformAction = capabilities.includes(
'your-capability-name'
);
curl
-XGET
-H 'x-api-key: YOUR_SALABLE_API_KEY'
'https://api.salable.app/licenses/check?productUuid=YOUR_PRODUCT_UUID&granteeIds=your-grantees-id&grace=3'
Grace Period
If the customer's payment fails, and you would like to give them a grace period
to rectify this — you can use the optional grace
parameter to extend the
license capability check by a specified number of days.
This is not currently supported on @salable/js
.