Skip to main content
Integrating PriceOS on your backend is the most secure way to use PriceOS and gives you access to all of our API capabilities.
1

Install

Create an API key in the PriceOS dashboard and add to your environment variables.
.env
PRICEOS_API_KEY=pos_ab234cdef...
npm i priceos
2

Generate types (optional, but highly recommended)

npx priceos generate-types
This will generate a local types file that you can include so all of your features are fully typed.Run with the --help option to see more configuration options.
Remember to regenerate types any time you create a new feature.
3

Create SDK client

import { PriceOS } from "priceos";
import type { MyFeatures } from "./priceos.types";

export const priceos = new PriceOS<MyFeatures>(process.env.PRICEOS_API_KEY);
4

Evaluate feature access


const { hasAccess } = await priceos.features.getAccess(
  "customer_123", // Your internal customer ID
  "premium_support" // Feature key
);

if (hasAccess) {
  // Allow action
}
For optimized performance, we recommend implementing a cache if feature access is evaluated frequently (or use our React hooks, which has a built-in cache).
Be sure to read Linking Stripe Customers to learn how to link Stripe customers to your own interal ID.
For more details, see Evaluating Feature Access.
5

Track usage (optional)

Only if you’re using PriceOS to track your customers’ usage for limit features.
await priceos.usage.track({
  customerId: "customer_123",
  featureKey: "team_seats",
  amount: 1,
});
For more details, see Tracking Usage.