# Create Bonus Source: https://docs.priceos.com/api-reference/endpoint/bonuses POST /v1/bonuses Create a one-time bonus amount for a customer feature. # Delete Bonus Source: https://docs.priceos.com/api-reference/endpoint/bonuses-delete DELETE /v1/bonuses/{bonusId} Delete an existing bonus that has not been consumed. # List Bonuses Source: https://docs.priceos.com/api-reference/endpoint/bonuses-list GET /v1/bonuses List bonuses for a customer, optionally filtered by feature key. # Update Bonus Source: https://docs.priceos.com/api-reference/endpoint/bonuses-update PUT /v1/bonuses/{bonusId} Update an existing bonus. # Create Customer Source: https://docs.priceos.com/api-reference/endpoint/create POST /v1/customers Create a customer record. # Archive Custom Product Source: https://docs.priceos.com/api-reference/endpoint/custom-products-archive POST /v1/custom-products/{productKey}/archive Archive or unarchive a custom product. Archiving clears its default status. # Create Custom Product Source: https://docs.priceos.com/api-reference/endpoint/custom-products-create POST /v1/custom-products Create a custom product, optionally with its complete feature access configuration and as the default product. # Delete Custom Product Source: https://docs.priceos.com/api-reference/endpoint/custom-products-delete DELETE /v1/custom-products/{productKey} Permanently delete an unassigned custom product. # Update Custom Product Source: https://docs.priceos.com/api-reference/endpoint/custom-products-update PUT /v1/custom-products/{productKey} Update a custom product's details or default status. # Checkout Source: https://docs.priceos.com/api-reference/endpoint/customer-checkout POST /v1/customers/{customerId}/checkout Create a Stripe checkout session for a customer using a Stripe product key, with an optional Stripe price ID override. # Open Customer Portal Source: https://docs.priceos.com/api-reference/endpoint/customer-portal POST /v1/customers/{customerId}/customer_portal Create a Stripe customer portal session URL for a customer. # Delete Customer Source: https://docs.priceos.com/api-reference/endpoint/delete DELETE /v1/customers/{customerId} Delete a customer record. # Get Feature Access Source: https://docs.priceos.com/api-reference/endpoint/feature-access GET /v1/feature-access Return feature access for a customer. # List Features Source: https://docs.priceos.com/api-reference/endpoint/features GET /v1/features List features for the project. # Archive Feature Source: https://docs.priceos.com/api-reference/endpoint/features-archive POST /v1/features/{featureKey}/archive Archive or unarchive a feature by feature key. # Create Feature Source: https://docs.priceos.com/api-reference/endpoint/features-create POST /v1/features Create a boolean or limit feature for the project. # Delete Feature Source: https://docs.priceos.com/api-reference/endpoint/features-delete DELETE /v1/features/{featureKey} Permanently delete a feature by feature key. # Update Feature Source: https://docs.priceos.com/api-reference/endpoint/features-update PUT /v1/features/{featureKey} Partially update a feature by feature key. # Get Customer Source: https://docs.priceos.com/api-reference/endpoint/get GET /v1/customers/{customerId} Fetch a customer by internal customer ID. # Link Customer IDs Source: https://docs.priceos.com/api-reference/endpoint/link POST /v1/customers/link Link a Stripe customer ID to your internal customer ID. If duplicate API and Stripe rows exist for the same person, PriceOS reconciles them. # Set Product Feature Access Source: https://docs.priceos.com/api-reference/endpoint/product-feature-access PUT /v1/products/{productKey}/feature-access Replace the complete feature access configuration for the latest product version. # Get Product Source: https://docs.priceos.com/api-reference/endpoint/product-get GET /v1/products/{productKey} Get the latest non-archived product by product key. # List Products Source: https://docs.priceos.com/api-reference/endpoint/products GET /v1/products List latest non-archived products for the project. # Update Customer Source: https://docs.priceos.com/api-reference/endpoint/update PUT /v1/customers/{customerId} Update a customer record. You can also use this endpoint to add or remove custom products. # Track Usage Source: https://docs.priceos.com/api-reference/endpoint/usage POST /v1/usage Record usage for a feature. # Track Usage (Batch) Source: https://docs.priceos.com/api-reference/endpoint/usage-batch POST /v1/usage/batch Record usage for multiple events (max 100). # Delete Usage Events (Batch) Source: https://docs.priceos.com/api-reference/endpoint/usage-delete POST /v1/usage/delete Delete usage events by IDs or by customer selectors. # Delete Usage Event Source: https://docs.priceos.com/api-reference/endpoint/usage-event-delete DELETE /v1/usage/{id} Delete a usage event by ID. # Get Usage Event Source: https://docs.priceos.com/api-reference/endpoint/usage-event-get GET /v1/usage/{id} Get a usage event by ID. # Update Usage Event Source: https://docs.priceos.com/api-reference/endpoint/usage-event-update PUT /v1/usage/{id} Update a usage event by ID. # List Usage Events Source: https://docs.priceos.com/api-reference/endpoint/usage-events POST /v1/usage/events List usage events for a customer and feature. # Set Usage Source: https://docs.priceos.com/api-reference/endpoint/usage-set POST /v1/usage/set Set absolute usage for the current period by recording an adjustment event. # Introduction Source: https://docs.priceos.com/api-reference/introduction Use the PriceOS API or SDKs from your backend Check out our [integration guide](/backend-integration) to get started. ## Base URL `https://api.priceos.com` ## Authorization Send your [API key](https://app.priceos.com/settings/api-keys) in the `x-api-key` header on every request. ```ts Node.js theme={null} const response = await fetch("https://api.priceos.com/v1/feature-access?customerId=customer_123", { headers: { "x-api-key": process.env.PRICEOS_API_KEY!, }, }); ``` ```bash cURL theme={null} curl -X GET "https://api.priceos.com/v1/feature-access?customerId=customer_123" \ -H "x-api-key: PRICEOS_API_KEY" ``` Never expose your API key in client-side code. ## Postman collection Download Postman collection ## Rate limits Rate limits are applied per API key (`x-api-key`) using a fixed 10-second window. * All routes: `1000` requests per `10` seconds per API key. * `PUT`, `POST`, `DELETE` routes: `500` requests per `10` seconds per API key. If you exceed a limit, the API returns `429 Too Many Requests`. # Backend Source: https://docs.priceos.com/backend-integration Integrate PriceOS in your backend with our [Node.js SDK](https://www.npmjs.com/package/priceos) or [API](/api-reference). Integrating PriceOS on your backend is the most secure way to use PriceOS and gives you access to all of our API capabilities. [Create an API key](https://app.priceos.com/settings/api-keys) in the PriceOS dashboard and add to your environment variables. ```bash title=".env" theme={null} PRICEOS_API_KEY=pos_ab234cdef... ``` ```bash npm theme={null} npm i priceos ``` ```bash pnpm theme={null} pnpm add priceos ``` ```bash yarn theme={null} yarn add priceos ``` ```bash bun theme={null} bun add priceos ``` ```bash npm theme={null} npx priceos generate-types ``` ```bash pnpm theme={null} pnpm dlx priceos generate-types ``` ```bash yarn theme={null} yarn dlx priceos generate-types ``` ```bash bun theme={null} bunx 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. ```ts Typed theme={null} import { PriceOS } from "priceos"; import type { MyFeatures } from "./priceos.types"; export const priceos = new PriceOS(process.env.PRICEOS_API_KEY); ``` ```ts Untyped theme={null} import { PriceOS } from "priceos"; export const priceos = new PriceOS(process.env.PRICEOS_API_KEY!); ``` ```ts Boolean features theme={null} const { hasAccess } = await priceos.features.getAccess( "customer_123", // Your internal customer ID "premium_support" // Feature key ); if (hasAccess) { // Allow action } ``` ```ts Limit features theme={null} const { hasAccess, usage } = await priceos.features.getAccess( "customer_123", // Your internal customer ID "credits" // Feature key ); if (hasAccess && !usage.hasReachedLimit) { // Allow access } ``` For optimized performance, we recommend implementing a cache if feature access is evaluated frequently (or use our [React hooks](/react-integration), which has a built-in cache). Be sure to read [Linking Stripe Customers](/linking-stripe-customers) to learn how to link Stripe customers to your own internal ID. For more details, see [Evaluating Feature Access](/evaluating-feature-access). Only if you're using PriceOS to track your customers' usage for limit features. ```ts Limit features theme={null} await priceos.usage.track({ customerId: "customer_123", featureKey: "team_seats", amount: 1, }); ``` For more details, see [Tracking Usage](/tracking-usage). [Create an API key](https://app.priceos.com/settings/api-keys) in the PriceOS dashboard and add to your environment variables. ```bash title=".env" theme={null} PRICEOS_API_KEY=pos_ab234cdef... ``` ```bash cURL theme={null} curl -X GET "https://api.priceos.com/v1/feature-access?customerId=customer_123" \ -H "x-api-key: PRICEOS_API_KEY" ``` ```js JavaScript theme={null} const response = await fetch( "https://api.priceos.com/v1/feature-access?customerId=customer_123", { headers: { "x-api-key": process.env.PRICEOS_API_KEY, }, } ); const featureAccess = await response.json(); ``` ```py Python theme={null} import requests response = requests.get( "https://api.priceos.com/v1/feature-access", params={"customerId": "customer_123"}, headers={"x-api-key": "PRICEOS_API_KEY"}, ) feature_access = response.json() ``` For more details, see [Evaluating Feature Access](/evaluating-feature-access) and [Linking Stripe Customers](/linking-stripe-customers). ```bash cURL theme={null} curl -X POST "https://api.priceos.com/v1/usage" \ -H "x-api-key: PRICEOS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "customerId": "customer_123", "featureKey": "team_seats", "amount": 1 }' ``` ```js JavaScript theme={null} const response = await fetch("https://api.priceos.com/v1/usage", { method: "POST", headers: { "x-api-key": process.env.PRICEOS_API_KEY, "Content-Type": "application/json", }, body: JSON.stringify({ customerId: "customer_123", featureKey: "team_seats", amount: 1, }), }); const result = await response.json(); ``` ```py Python theme={null} import requests response = requests.post( "https://api.priceos.com/v1/usage", headers={ "x-api-key": "PRICEOS_API_KEY", "Content-Type": "application/json", }, json={ "customerId": "customer_123", "featureKey": "team_seats", "amount": 1, }, ) result = response.json() ``` For more details, see [Tracking Usage](/tracking-usage). # Billing Source: https://docs.priceos.com/billing Manage your plan, understand MAU, and embed your pricing table. You can manage billing in the [billing page](https://app.priceos.com/settings/billing). ## Update your plan Go to [Billing Settings](https://app.priceos.com/settings/billing) to upgrade or change your plan. ## How Monthly active users (MAU) are tracked PriceOS tracks MAU using unique `customerId` values seen in successful live API requests during each monthly MAU period. What counts toward MAU: * `customerId` in query params (for example `?customerId=customer_123`) * `customerId` in route params (for example `/v1/customers/{customerId}/...`) * `customerId` in JSON request bodies * `events[].customerId` in batch request bodies How counting works: * Unique per month: each `customerId` is counted once per monthly MAU period. * Repeated requests for the same `customerId` in the same monthly MAU period still count as 1. * Tracking is applied only for `live` API traffic. * When a request returns an error status, the MAU tracking for that request is rolled back. * MAU is reviewed monthly for both monthly and yearly plans. ## What happens if you exceed MAUs for your current plan No surprise fees. An occasional spike in MAUs won't trigger extra charges or stop your PriceOS from working. A single monthly MAU period over your limit requires no action. If MAU drops back within your tier the following month, nothing happens. If usage exceeds your tier for two consecutive monthly MAU periods, we'll notify you to upgrade. The change is pro-rated so you only pay the difference. If you enter a third consecutive monthly MAU period over your limit without upgrading, your dashboards are temporarily locked. Even while locked, PriceOS will continue to work in the background. Dashboards are automatically unlocked once your account is back within the appropriate tier. You can also unlock them at any time by upgrading to the appropriate tier. If the spike is temporary, you can upgrade to restore access and downgrade again when traffic drops. Downgrades are pro-rated too, so you won't lose out. You're never locked into a higher plan when your usage no longer requires it. This works the same way on both monthly and yearly billing. # Creating Customers Source: https://docs.priceos.com/creating-customers Learn how to create customers using our API. If you have [custom products](/custom-products) that you need to assign to customers that don't exist in Stripe, you'll need to create those customers manually using our API. There is no need to create customers that already exist in Stripe customers, but you will need to [link them with your own internal ID](/linking-stripe-customers). *** ## Create a customer You can create a customer with just a customer ID. ```ts TypeScript theme={null} const customer = await priceos.customers.create({ customerId: "customer_123", // Your own internal customer/user ID }); ``` ```bash cURL theme={null} curl -X POST "https://api.priceos.com/v1/customers" \ -H "x-api-key: PRICEOS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "customerId": "customer_123" }' ``` Customers will also be created anytime you try to [evaluate feature access](/api-reference/endpoint/feature-access) or [track usage](/api-reference/endpoint/usage) with a new customer ID. *** ## Create a customer with name and email ```ts TypeScript theme={null} const customer = await priceos.customers.create({ customerId: "customer_123", name: "Alex Johnson", email: "alex@acme.com", }); ``` ```bash cURL theme={null} curl -X POST "https://api.priceos.com/v1/customers" \ -H "x-api-key: PRICEOS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "customerId": "customer_123", "name": "Alex Johnson", "email": "alex@acme.com" }' ``` You can update the customer at any time using [update customer](/api-reference/endpoint/update). *** ## Create a customer with usage start date The `usageStartedAt` is only needed if you have a limit feature that resets based on billing period and you use PriceOS to track usage for it. In that case, the `usageStartedAt` is the anchor we use to determine when usage will be reset for this user. ```ts TypeScript theme={null} const customer = await priceos.customers.create({ customerId: "customer_123", usageStartedAt: Date.parse("2024-01-01T00:00:00.000Z"), }); ``` ```bash cURL theme={null} curl -X POST "https://api.priceos.com/v1/customers" \ -H "x-api-key: PRICEOS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "customerId": "customer_123", "usageStartedAt": 1704067200000 }' ``` If no `usageStartedAt` is provided, we'll just use the date the customer was created in our system. *** ## Create a customer and assign custom products ```ts TypeScript theme={null} const customer = await priceos.customers.create({ customerId: "customer_123", customProductKeys: ["custom_basic", "custom_addon"], }); ``` ```bash cURL theme={null} curl -X POST "https://api.priceos.com/v1/customers" \ -H "x-api-key: PRICEOS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "customerId": "customer_123", "customProductKeys": ["custom_basic", "custom_addon"] }' ``` To [remove custom products](/managing-customers#remove-custom-products) update the customer with the remaining `customProductKeys` (or an empty list). [Stripe products](/stripe-products) and [default products](/custom-products#default-custom-products) cannot be manually assigned. # Creating Features Source: https://docs.priceos.com/creating-features Learn how to create boolean and limit features. You can create two types of features in PriceOS: * [Boolean features](#boolean-features) * [Limit features](#limit-features) You can create features on the features page, product details page, or with the [create feature API](/api-reference/endpoint/features-create). *** ## Boolean features Boolean features are on/off access to a feature (e.g. Priority support, Advanced analytics, API access, etc) To create one: 1. Go to [Features](https://app.priceos.com/features) 2. Click the New Feature button 3. Add a feature name and key 4. Select Boolean as the feature type 5. Click the Create Feature button *** ## Limit features Limit features are a numeric cap (e.g. Credits, Team Seats, API requests, etc.). You can optionally use PriceOS to track usage for your limit features. To create one: 1. Go to [Features](https://app.priceos.com/features) 2. Click the New Feature button 3. Add a feature name and key 4. Select Limit as the feature type 5. Click the Create Feature button Unlike boolean features, you can track usage for your limit feature to keep track of when customers hit limits. 1. Go to [Features](https://app.priceos.com/features) 2. Click the New Feature button 3. Add a feature name and key 4. Select Limit as the feature type 5. Click the Track usage with PriceOS switch 6. Select a reset interval * Never - Usage will never reset * Monthly - Usage will reset monthly for customers based on resets when You can choose daily, weekly, and yearly reset intervals by clicking the More ... button 7. Select a resets when * Billing period start - Usage will reset based on their Stripe subscription date OR their [`usageStartedAt`](/api-reference/endpoint/create#body-usage-started-at) date if not a Stripe customer. * Start of month - Usage will reset at the start of the month for all customers regardless of when they signed up Billing-period resets apply to Stripe-linked customers. For non-Stripe customers, define usage start using [`usageStartedAt`](/api-reference/endpoint/create#body-usage-started-at) (defaults to the date the customer was created if not provided). 8. Click the Create Feature button See [Tracking Usage](/tracking-usage) to learn more. *** ## Create features with the API Use the API when you want to create features from your own provisioning flow or internal tools. ```ts theme={null} import { PriceOS } from "priceos"; const priceos = new PriceOS(process.env.PRICEOS_API_KEY!); await priceos.features.create({ name: "API Calls", featureKey: "api_calls", type: "limit", tracksUsage: true, usageResetInterval: "month", usageResetAnchor: "calendar", }); ``` You can also [update](/api-reference/endpoint/features-update), [archive](/api-reference/endpoint/features-archive), or [delete](/api-reference/endpoint/features-delete) features by feature key. # Creating Overrides Source: https://docs.priceos.com/creating-overrides Customer overrides let you change feature access for individual customers. Customer overrides are useful if you need to... * Grant access to a feature for a single customer * Increase or reduce a limit for a single customer Overrides persist on customers until they expire or you remove them. ## Create an override in the web app Go to the [customers page](https://app.priceos.com/customers) and find and click on a customer. Scroll down to the overrides section and click the Create Override button Customer override section in customer details page in PriceOS Select a feature, specify the feature access override, and optionally set a reason and expiration date. Customer override dialog in PriceOS Click the Create Override button Overrides apply immediately and only affect that customer. # Custom Products Source: https://docs.priceos.com/custom-products Custom products let you define feature access for customers that don’t exist in Stripe. Custom products are useful for things like... * Freemium plans * Free trials * Lifetime deals * Internal users or test accounts * Enterprise contracts handled off-Stripe Unlike [Stripe products](/stripe-products), custom products are assigned to customers manually using our API. *** ## How to create a custom product 1. Go to the [products page](https://app.priceos.com/products) 2. Click the New Product button 3. Enter a name for the product 4. Click the Create button You will then be taken to the product details page where you can [define feature access](/defining-feature-access) for your product. *** ## How to assign custom products to customers You can assign products when you create a custom or anytime after. ```ts TypeScript theme={null} const customer = await priceos.customers.create({ customerId: "customer_123", customProductKeys: ["custom_basic"], }); ``` ```bash cURL theme={null} curl -X POST "https://api.priceos.com/v1/customers" \ -H "x-api-key: PRICEOS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "customerId": "customer_123", "customProductKeys": ["custom_basic"] }' ``` ```ts TypeScript theme={null} const customer = await priceos.customers.update({ customerId: "customer_123", customProductKeys: ["custom_basic"], }); ``` ```bash cURL theme={null} curl -X PUT "https://api.priceos.com/v1/customers/customer_123" \ -H "x-api-key: PRICEOS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "customProductKeys": ["custom_basic"] }' ``` For more details, see [Create Customer](/api-reference/endpoint/create) and [Update Customer](/api-reference/endpoint/update). If you have [limit features](/creating-features#limit-features) that reset periodically based on billing period, you can set the [`usageStartedAt`](/api-reference/endpoint/create#body-usage-started-at) field to specify the reset anchor. If not specified, we'll use the date the customer was created. *** ## Removing custom products from customers To remove custom products from customers, just update the customer with whatever custom product keys the customer should have. ```ts TypeScript theme={null} const customer = await priceos.customers.update({ customerId: "customer_123", customProductKeys: [], }); ``` ```bash cURL theme={null} curl -X PUT "https://api.priceos.com/v1/customers/customer_123" \ -H "x-api-key: PRICEOS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "customProductKeys": [] }' ``` For more details, see [Update Customer](/api-reference/endpoint/update). *** ## Default custom products Default custom products let you define feature access for everyone else who doesn't have a product, which can be useful for things like freemium plans. ### How default custom products work There are some important points to understand about default custom products... * You can only have one default product * Default products get automatically applied to any customers not assigned a product * Default products cannot be manually assigned * Default products cannot have multiple versions If a customer has either Stripe-derived products or assigned custom products, the default product is not used. ### Creating a default product You can set any custom product as the default product by clicking the default switch when creating or editing a custom product. Creating a default custom product # Defining Feature Access Source: https://docs.priceos.com/defining-feature-access Learn how to define feature access and set limits for your features and products. Feature access gets defined per feature per product. By default, all features will have a "No Access" definition for all products until you change it. Need different feature access definitions for the same product? Create multiple [product versions](/product-versioning). *** ## How to define feature access You can define feature access by product or by feature. You can define feature access by products by clicking on any product in the [products page](https://app.priceos.com/products). This is useful when you are creating a new product or migrating to PriceOS. Defining feature access by product You can also copy feature access from another product by clicking the More button and selecting the "Duplicate Feature Access" button from the menu. You can define feature access by feature by clicking on any feature in the [features page](https://app.priceos.com/features). This is useful when you are creating a new feature. Defining feature access by feature *** ## Boolean features Define access for boolean features by toggling the switch next to the feature. Defining boolean feature access with switch toggle *** ## Limit features Define access for limit features by selecting an option in the dropdown. Limit features can have the following values: * **No access**: Customer does not have access to the feature * **Custom limit**: A numeric limit you set * **Unlimited**: Customer has unlimited access Defining limit feature access with dropdown *** ## Saving changes After you've made all of your changes, you need to save them by clicking the Save button. Save feature access button If the product you are changing has customers attached to it and you've integrated the API into your application, you'll be asked whether or not you want to create another product version. Product version dialog If you want your changes to apply to all customers immediately, don't create a new product version. If you want your changes to only apply to new customers, create a new product version. See [Product Versioning](/product-versioning) to learn more. # Displaying Bonuses Source: https://docs.priceos.com/displaying-bonuses Show customers how much bonus usage they have left and how much was consumed. You can find customers' usage info for bonuses from the following fields when [evaluating feature access](/api-reference/endpoint/feature-access)... * `bonusRemaining` * `bonusUsed` ```tsx React theme={null} import { useFeatureAccess } from "priceos/react"; import type { MyFeatures } from "./priceos.types"; export function BonusUsageCard() { const { usage, isLoading } = useFeatureAccess("credits"); if (isLoading) return
Loading...
; if (!usage) return
No usage data available.
; return (

Bonus remaining: {usage.bonusRemaining}

Bonus used: {usage.bonusUsed}

); } ``` ```ts Node.js theme={null} import { PriceOS } from "priceos"; import type { MyFeatures } from "./priceos.types"; const priceos = new PriceOS(process.env.PRICEOS_API_KEY!); const credits = await priceos.features.getAccess("customer_123", "credits"); const bonusRemaining = credits.usage.bonusRemaining; const bonusUsed = credits.usage.bonusUsed; ``` ```bash cURL theme={null} curl -X GET "https://api.priceos.com/v1/feature-access?customerId=customer_123" \ -H "x-api-key: PRICEOS_API_KEY" ```
# Displaying Usage Source: https://docs.priceos.com/displaying-usage Show current usage totals and usage history to your customers for limit features. Often, you'll need to show your customers how much usage they have available on your UI. You can use our API to do this. ## Show current totals Most usage information for a customer is available when you evaluate a customer's feature access via the [feature access endpoint](/api-reference/endpoint/feature-access). ```tsx React theme={null} import { useFeatureAccess } from "priceos/react"; import type { MyFeatures } from "./priceos.types"; export function CreditsUsageCard() { const { usage, isUnlimited, limit, isLoading } = useFeatureAccess("credits"); if (isLoading) return
Loading...
; if (!usage) return
No usage data available.
; const used = usage.used; const effectiveLimit = isUnlimited ? null : limit; const hasReachedLimit = usage.hasReachedLimit; const bonusRemaining = usage.bonusRemaining; const bonusUsed = usage.bonusUsed; const nextReset = usage.nextReset; const label = isUnlimited ? "Unlimited" : `${used} / ${effectiveLimit}`; return (

Credits used: {label}

Bonus remaining: {bonusRemaining}

Bonus used: {bonusUsed}

Limit reached: {hasReachedLimit ? "Yes" : "No"}

Next reset: {nextReset ? new Date(nextReset).toLocaleString() : "N/A"}

); } ``` ```ts Node.js theme={null} import { PriceOS } from "priceos"; import type { MyFeatures } from "./priceos.types"; const priceos = new PriceOS(process.env.PRICEOS_API_KEY!); const credits = await priceos.features.getAccess("customer_123", "credits"); const used = credits.usage.used; const limit = credits.isUnlimited ? null : credits.limit; const hasReachedLimit = credits.usage.hasReachedLimit; const bonusRemaining = credits.usage.bonusRemaining; const bonusUsed = credits.usage.bonusUsed; const nextReset = credits.usage.nextReset; const label = credits.isUnlimited ? "Unlimited" : `${used} / ${limit}`; ``` ```bash cURL theme={null} curl -X GET "https://api.priceos.com/v1/feature-access?customerId=customer_123" \ -H "x-api-key: PRICEOS_API_KEY" ```
## The `limit` field is the base limit set in the feature. It does not include any bonuses. ## Show usage history If you want a list of all the usage events, then you can use our [list usage events endpoint](/api-reference/endpoint/usage-events). ```tsx React theme={null} import { useUsageEvents } from "priceos/react"; import type { MyFeatures } from "./priceos.types"; export function CreditsUsageHistory() { const { usageEvents, hasMore, getMore, isLoading } = useUsageEvents("credits", { period: "current", limit: 20, }); if (isLoading) return
Loading...
; return (
    {usageEvents.map((event) => (
  • {event.amount} at {new Date(event.occurredAt).toLocaleString()}
  • ))}
{hasMore ? : null}
); } ``` ```ts TypeScript theme={null} const { usageEvents, hasMore } = await priceos.usage.listEvents({ customerId: "customer_123", featureKey: "credits", period: "current", limit: 20, offset: 0, }); ``` ```bash cURL theme={null} curl -X POST "https://api.priceos.com/v1/usage/events" \ -H "x-api-key: PRICEOS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "customerId": "customer_123", "featureKey": "credits", "period": "current", "limit": 20, "offset": 0 }' ```
You can pass `customRange` to fetch a specific time window. Provide either `customRange` or `period`, not both. # Evaluating Feature Access Source: https://docs.priceos.com/evaluating-feature-access Learn how to evaluate feature access in your application using our [API](/api-reference). Be sure to check out [Linking Stripe Customers](/linking-stripe-customers) to learn more about how to identify Stripe customers with your own internal customer ID. ## Evaluating access for a single feature ```tsx React theme={null} import { useFeatureAccess } from "priceos/react"; import type { MyFeatures } from "./priceos.types"; export function PrioritySupportButton() { const { hasAccess, isLoading } = useFeatureAccess("priority_support"); const onClick = () => { if (!hasAccess){ // Customer does not have access } // Allow action } if (isLoading) return
Loading...
; return ( ); } ``` ```ts Node.js theme={null} import { PriceOS } from "priceos"; import type { MyFeatures } from "./priceos.types"; const priceos = new PriceOS(process.env.PRICEOS_API_KEY!); const { hasAccess } = await priceos.features.getAccess( "customer_123", // Your internal customer ID "priority_support" // Feature key ); if (hasAccess) { // Allow action } ``` ```bash cURL theme={null} curl -X GET "https://api.priceos.com/v1/feature-access?customerId=customer_123" \ -H "x-api-key: PRICEOS_API_KEY" ```
`usage` will be included if you're using PriceOS to track usage for that feature. ```tsx React theme={null} import { useFeatureAccess } from "priceos/react"; import type { MyFeatures } from "./priceos.types"; export function CreateNewButton() { const { hasAccess, usage, limit, isLoading } = useFeatureAccess("credits"); const onClick = () => { if (!hasAccess){ // Customer does not have access } // If using PriceOS to track usage... if (usage?.hasReachedLimit){ // Customer has hit usage limit } // If using your own system to track usage... if (currentUsage >= limit){ // Customer has hit usage limit } } return ( ); } ``` ```ts Node.js theme={null} import { PriceOS } from "priceos"; import type { MyFeatures } from "./priceos.types"; const priceos = new PriceOS(process.env.PRICEOS_API_KEY!); const { hasAccess, usage, limit } = await priceos.features.getAccess( "customer_123", // Your internal customer ID "credits" ); if (!hasAccess){ // Customer does not have access } // If using PriceOS to track usage... if (usage?.hasReachedLimit){ // Customer has hit usage limit } // If using your own system to track usage... if (currentUsage >= limit){ // Customer has hit usage limit } ``` ```bash cURL theme={null} curl -X GET "https://api.priceos.com/v1/feature-access?customerId=customer_123" \ -H "x-api-key: PRICEOS_API_KEY" ``` The `hasAccess` field indicates whether the customer has access to the feature in general. It does not indicate that the usage limit has been reached. Use the `usage.hasReachedLimit` field for that.
*** ## Evaluate access for all features Boolean features are simple on/off checks using `hasAccess`. ```tsx React theme={null} import { useFeatureAccess } from "priceos/react"; import type { MyFeatures } from "./priceos.types"; export function PrioritySupportButton() { const { featureAccess, isLoading } = useFeatureAccess(); const onClick = () => { const hasAccess = featureAccess.priority_support.hasAccess; if (hasAccess){ // Allow action } } if (isLoading) return
Loading...
; return ; } ``` ```ts Node.js theme={null} import { PriceOS } from "priceos"; import type { MyFeatures } from "./priceos.types"; const priceos = new PriceOS(process.env.PRICEOS_API_KEY!); const featureAccess = await priceos.features.getAccess( "customer_123" // Your internal customer ID ); if (featureAccess.priority_support.hasAccess) { // Allow action } ``` ```bash cURL theme={null} curl -X GET "https://api.priceos.com/v1/feature-access?customerId=customer_123" \ -H "x-api-key: PRICEOS_API_KEY" ```
Limit features return usage data and the current limit window. ```tsx React theme={null} import { useFeatureAccess } from "priceos/react"; import type { MyFeatures } from "./priceos.types"; export function CreateNewButton() { const { featureAccess, isLoading } = useFeatureAccess(); const onClick = () => { const { hasAccess, usage, limit } = featureAccess.credits ?? {} if (!hasAccess){ // Customer does not have access } // If using PriceOS to track usage... if (usage?.hasReachedLimit){ // Customer has hit usage limit } // If using your own system to track usage... if (currentUsage >= limit){ // Customer has hit usage limit } } if (isLoading) return
Loading...
; return ; } ``` ```ts Node.js theme={null} import { PriceOS } from "priceos"; import type { MyFeatures } from "./priceos.types"; const priceos = new PriceOS(process.env.PRICEOS_API_KEY!); const featureAccess = await priceos.features.getAccess( "customer_123" // Your internal customer ID ); const { hasAccess, usage, limit } = featureAccess.credits; if (!hasAccess){ // Customer does not have access } // If using PriceOS to track usage... if (usage?.hasReachedLimit){ // Customer has hit usage limit } // If using your own system to track usage... if (currentUsage >= limit){ // Customer has hit usage limit } ``` ```bash cURL theme={null} curl -X GET "https://api.priceos.com/v1/feature-access?customerId=customer_123" \ -H "x-api-key: PRICEOS_API_KEY" ```
The `hasAccess` field indicates whether the customer has access to the feature in general. It does not indicate that the usage limit has been reached. Use the `usage.hasReachedLimit` field for that.
# Granting Bonuses Source: https://docs.priceos.com/granting-bonuses You can grant bonuses using the web app or API. To grant bonues to customers via the Web App... Go to the [customers page](https://app.priceos.com/customers) and find and click on a customer. Scroll down to the bonuses section and click the Grant Bonus button Bonuses section in customer details page in PriceOS Select a feature, input an amount, and optionally set a reason and expiration date Grant bonus dialog page in PriceOS Click the Grant Bonus button You can use the [create bonus endpoint](/api-reference/endpoint/bonuses) to grant bonuses to a customer. ```ts TypeScript theme={null} const result = await priceos.bonuses.create({ customerId: "customer_123", featureKey: "api_calls", amount: 100, expiresAt: Date.parse("2026-12-31T23:59:59.000Z"), reason: "promotion", metadata: { campaign: "winter_promo", }, }); ``` ```bash cURL theme={null} curl -X POST "https://api.priceos.com/v1/bonuses" \ -H "x-api-key: PRICEOS_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "customerId": "customer_123", "featureKey": "api_calls", "amount": 100, "expiresAt": 1798761599000, "reason": "promotion", "metadata": { "campaign": "winter_promo" } }' ``` # Credits Source: https://docs.priceos.com/guides/credit-systems