Skip to main content

Overview

The Revstack class is the main entry point for the Node SDK. Initialize it with your secret API key to access all SDK modules.

Constructor

new Revstack(options)

Creates a new Revstack SDK instance.
options
RevstackOptions
required
Configuration options for the SDK client.
revstack
Revstack
Returns a configured Revstack client instance with access to all modules.

Client Modules

The Revstack client provides access to the following modules:

Data Plane (Daily Operations)

customers
CustomersClient
Manage end-user (customer) records.View documentation →
subscriptions
SubscriptionsClient
Create, cancel, and manage subscriptions.View documentation →
entitlements
EntitlementsClient
Check feature access and query entitlements.View documentation →
usage
UsageClient
Report and query metered feature usage.View documentation →
wallets
WalletsClient
Manage customer wallet balances.View documentation →
plans
PlansClient
Query billing plans (read-only).View documentation →
invoices
InvoicesClient
Query billing invoices (read-only).View documentation →
webhooks
WebhooksClient
Verify inbound webhook signatures.View documentation →

Control Plane (Administration)

admin
AdminClient
Administrative operations for plans, entitlements, integrations, and environments.View documentation →

Usage Example

import { Revstack } from "@revstackhq/node";

// Initialize the client
const revstack = new Revstack({
  secretKey: process.env.REVSTACK_SECRET_KEY!,
});

// Data Plane: Check entitlements
const { allowed } = await revstack.entitlements.check(
  "usr_abc",
  "api-calls"
);

if (!allowed) {
  throw new Error("Feature not available on your plan");
}

// Control Plane: Manage plans via admin
await revstack.admin.plans.upsert({
  slug: "pro",
  name: "Pro",
  prices: [{ amount: 4900, currency: "USD", billingInterval: "month" }],
});

Error Handling

The SDK throws typed errors that you can catch and handle:
import { 
  Revstack, 
  RevstackError, 
  RevstackAPIError, 
  RateLimitError 
} from "@revstackhq/node";

try {
  const customer = await revstack.customers.get("usr_abc");
} catch (error) {
  if (error instanceof RateLimitError) {
    console.error("Rate limit exceeded");
  } else if (error instanceof RevstackAPIError) {
    console.error(`API error: ${error.message}`);
  }
}

TypeScript Support

The SDK is written in TypeScript and includes comprehensive type definitions:
import type { 
  Customer, 
  Subscription, 
  Entitlement,
  Plan,
  Invoice
} from "@revstackhq/node";

Build docs developers (and LLMs) love