Skip to main content
Integration with Unprice is designed to be seamless. Follow these steps to start managing your pricing.

1. Configure your Model

Pricing in Unprice is decoupled from your code. You define your model in the dashboard first.
  1. Create a Plan: Give it a name like “Pro” and a slug like pro.
  2. Create a Plan Version: Plans are versioned so you can safely iterate.
  3. Add Features: Define what you are selling (e.g., “API Requests”) and choose a pricing type (Flat, Tiered, or Usage-based).
  4. Publish: Once published, your version is ready to accept subscriptions.

2. Install & Initialize

Install our type-safe SDK and initialize it with your Project API Key.
npm install @unprice/api
import { Unprice } from "@unprice/api";

const unprice = new Unprice({
  token: process.env.UNPRICE_TOKEN // Found in your Project Settings
});

3. Verify Access (Entitlements)

Before performing an action, check if the customer has access and if they have enough balance for the specific operation.
const { result } = await unprice.customers.can({
  customerId: "cust_123",
  featureSlug: "ai-generations",
  usage: 5 // Check if they can consume 5 units right now
});

if (result?.allowed) {
  // 1. Perform your operation...

  // 2. Then report the usage to update their balance
  await unprice.customers.reportUsage({
    customerId: "cust_123",
    featureSlug: "ai-generations",
    usage: 5,
    idempotenceKey: "unique-id-for-this-request"
  });
}

4. Subscribe a Customer

Subscribe a customer to your latest plan version in a single call. Unprice handles the checkout redirect and provider linking.
const { result } = await unprice.customers.signUp({
  email: "[email protected]",
  planSlug: "pro", // Subscribes them to the latest version of 'pro'
  successUrl: "https://yourapp.com/dashboard",
  cancelUrl: "https://yourapp.com/pricing"
});

// Redirect the user to the checkout URL provided in result.url

Next Steps