SDK and HTTP integration
The entitlements SDK is coming soon. Use the HTTP check API today from your server with a usage key, and keep access checks and caching in your app.
@comecero/entitlements is coming soon. It is not published on npm yet, so you cannot install or import it today. Use the check API over plain HTTP instead.
Comecero staff must turn entitlements on for your shop before you set up features, feature sets and overrides. Ask support to enable it. Metered features also need usage billing turned on.
Server
Call GET https://usage.comecero.com/v1/entitlements with a usage key, not a Comecero API token:
curl "https://usage.comecero.com/v1/entitlements?customer_id=user_8412&feature=sso" \
-H "Authorization: Bearer $COMECERO_USAGE_KEY"With Node.js 18 or later, or another server runtime with fetch, no package is needed:
const url = new URL("https://usage.comecero.com/v1/entitlements");
url.searchParams.set("customer_id", "user_8412");
url.searchParams.set("feature", "sso");
const response = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.COMECERO_USAGE_KEY}` },
signal: AbortSignal.timeout(2000),
});
if (!response.ok) throw new Error(`Entitlement check failed: ${response.status}`);
const answer = await response.json();
const sso = answer.entitlements.find((row) => row.feature === "sso");
const allowed = sso?.has_access === true;Use the customer's external_id, or their Comecero customer_id when none is set. The key selects the shop and live or test mode. Omit feature to read every feature. Read the returned has_access before doing the work on your server.
Cache and errors
- Cache a successful answer for at most 60 seconds, or until the earliest
valid_untilin its rows, whichever comes first. - When an all-feature answer has
reason: "usage_not_read", ask for that feature alone. A finite hard limit stays denied while its usage cannot be read. - On
429, wait for theRetry-Afterseconds before retrying. Retry temporary network failures or503with a bounded delay. Do not retry invalid input or an unknown feature as if access were granted. - Decide how your app handles an outage. Denying access until a successful check avoids granting access without an answer. Reusing an earlier answer can keep paying customers working, but may retain access after a cancellation or expired override.
These are rules for your integration to implement. The HTTP examples above make one request and do not add caching or retries.
Pages
Keep the usage key on your server. A browser page should ask your backend, which reads the signed-in customer's id from your session and calls the check API for that customer. Do not let a query parameter choose another customer.
A page check helps show or hide controls. Always check again on your server before doing the work.
Webhooks
Subscribe to entitlement:changed with active: true. Check the signature using the raw body before parsing JSON. The signing key is the subscription's signature_key, or your account's key.
Drop an event_id you have already handled and keep the highest data.version for each customer. Clear cached answers for data.external_id when a new change arrives. Deliveries can arrive twice or out of order. See when access changes.
Customer entitlements
Read what one customer can do from the Comecero API, with the override and the purchase behind each feature, for support tools and your back office.
Reports and analytics
MRR, churn, sales, card approval, storefront visits and usage for your shop, in the dashboard, the API and Claude, with what each number means.