Skip to main content

Overview

The AdminClient provides access to Control Plane operations for managing your Revstack infrastructure. It includes submodules for managing plans, entitlements, integrations, and environments.

Submodules

admin.plans

Manage billing plans with full CRUD operations and idempotent upserts.
revstack.admin.plans
Methods:
  • list(params?) - List all plans with optional filters
  • get(planId) - Retrieve a plan by ID with nested prices and entitlements
  • create(params) - Create a new billing plan
  • update(planId, params) - Update an existing plan’s attributes
  • delete(planId) - Delete a plan (fails if it has active subscriptions)
  • upsert(params) - Idempotently create or update a plan by slug
Example:
// Upsert a plan (used by CLI for Billing as Code)
await revstack.admin.plans.upsert({
  slug: "pro",
  name: "Pro",
  status: "active",
  type: "paid",
  prices: [
    { amount: 4900, currency: "USD", billingInterval: "month" },
    { amount: 49000, currency: "USD", billingInterval: "year" },
  ],
  entitlements: [
    { entitlementSlug: "api-calls", valueLimit: 10000 },
    { entitlementSlug: "advanced-analytics", valueBool: true },
  ],
});
View full documentation →

admin.entitlements

Manage entitlement definitions with full CRUD operations and idempotent upserts.
revstack.admin.entitlements
Methods:
  • list(params?) - List all entitlement definitions
  • get(entitlementId) - Retrieve an entitlement definition by ID
  • create(params) - Create a new entitlement definition
  • update(entitlementId, params) - Update an existing entitlement
  • delete(entitlementId) - Delete an entitlement (fails if any plans reference it)
  • upsert(params) - Idempotently create or update an entitlement by slug
Example:
// Upsert an entitlement definition
await revstack.admin.entitlements.upsert({
  slug: "api-calls",
  name: "API Calls",
  type: "metered",
  unitType: "count",
});
View full documentation →

admin.integrations

Manage payment provider integrations (Stripe, Paddle, etc.) with CRUD operations and monitoring.
revstack.admin.integrations
Methods:
  • list(params?) - List all integrations with optional filters
  • get(integrationId) - Retrieve an integration by ID
  • create(params) - Create a new payment provider integration
  • update(integrationId, params) - Update integration credentials or settings
  • delete(integrationId) - Delete an integration (stops webhook processing)
  • listEvents(integrationId, params?) - List webhook events received by an integration
  • listMetrics(integrationId, params?) - List hourly aggregated metrics
Example:
// Create a Stripe integration
const integration = await revstack.admin.integrations.create({
  provider: "stripe",
  credentials: { apiKey: process.env.STRIPE_SECRET_KEY },
  webhookSecret: process.env.STRIPE_WEBHOOK_SECRET,
});

// View recent webhook events
const { data: events } = await revstack.admin.integrations.listEvents(
  integration.id
);
View full documentation →

admin.environments

Manage deployment environments with separate API keys and auth configurations.
revstack.admin.environments
Methods:
  • list(params?) - List all environments
  • get(environmentId) - Retrieve an environment by ID
  • create(params) - Create a new deployment environment
  • update(environmentId, params) - Update environment name or auth config
  • delete(environmentId) - Delete an environment (invalidates API keys immediately)
  • rotateKeys(environmentId) - Rotate API keys for security
Example:
// Create a staging environment
const env = await revstack.admin.environments.create({
  name: "staging",
  authProvider: "supabase",
  authJwksUri: "https://my-project.supabase.co/.well-known/jwks.json",
});

console.log(`Public Key: ${env.apiKeyPublic}`);
console.log(`Secret Key: ${env.apiKeySecret}`);
View full documentation →

admin.plans

list()

const response = await revstack.admin.plans.list(params);
params
ListPlansParams
Filter and pagination parameters (same as revstack.plans.list()).

get()

const plan = await revstack.admin.plans.get(planId);
planId
string
required
The plan’s unique identifier.

create()

const plan = await revstack.admin.plans.create(params);
params
CreatePlanParams
required

update()

const plan = await revstack.admin.plans.update(planId, params);
Partially update a plan’s attributes. Does not modify prices or entitlements — use upsert() for that.
planId
string
required
The plan’s unique identifier.
params
UpdatePlanParams
required
Fields to update (all optional).

delete()

const result = await revstack.admin.plans.delete(planId);
Delete a plan. Fails if the plan has active subscriptions.

upsert()

const plan = await revstack.admin.plans.upsert(params);
Idempotently create or update a plan by its slug. This is the primary method used by the CLI for Billing as Code deployments.
params
UpsertPlanParams
required
Full plan state including prices and entitlements. The slug acts as the idempotency key.

admin.entitlements

upsert()

const entitlement = await revstack.admin.entitlements.upsert(params);
params
UpsertEntitlementParams
required

admin.integrations

create()

const integration = await revstack.admin.integrations.create(params);
params
CreateIntegrationParams
required

listEvents()

const response = await revstack.admin.integrations.listEvents(
  integrationId,
  params
);
List webhook events received by an integration. Useful for debugging.
integrationId
string
required
The integration to query events for.
params
ListProviderEventsParams

listMetrics()

const response = await revstack.admin.integrations.listMetrics(
  integrationId,
  params
);
List hourly aggregated metrics for an integration.
integrationId
string
required
The integration to query metrics for.
params
ListMetricsParams

admin.environments

create()

const environment = await revstack.admin.environments.create(params);
params
CreateEnvironmentParams
required

rotateKeys()

const keys = await revstack.admin.environments.rotateKeys(environmentId);
Rotate both the public and secret API keys for an environment. The old keys become invalid immediately. Use this after a security incident.
environmentId
string
required
The environment whose keys to rotate.
keys
object
apiKeyPublic
string
New public API key.
apiKeySecret
string
New secret API key.
Example:
const { apiKeyPublic, apiKeySecret } = 
  await revstack.admin.environments.rotateKeys("env_prod");

console.log("New keys generated:");
console.log(`Public: ${apiKeyPublic}`);
console.log(`Secret: ${apiKeySecret}`);

Build docs developers (and LLMs) love