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.
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 );
Filter and pagination parameters (same as revstack.plans.list()).
get()
const plan = await revstack . admin . plans . get ( planId );
The plan’s unique identifier.
create()
const plan = await revstack . admin . plans . create ( params );
Human-readable plan name.
Optional description for pricing pages.
Plan status: draft, active, archived. Default: draft
Plan type: free, paid, custom. Default: paid
Whether this is the default plan.
Whether this plan is publicly visible.
Prices to create alongside the plan.
entitlements
UpsertPlanEntitlementInput[]
Entitlement allocations to create.
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.
The plan’s unique identifier.
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.
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
URL-safe unique slug (acts as idempotency key).
Entitlement type: boolean, metered, tiered.
Unit of measurement: count, bytes, seconds, etc.
admin.integrations
create()
const integration = await revstack . admin . integrations . create ( params );
params
CreateIntegrationParams
required
Payment provider name: stripe, paddle, etc.
credentials
Record<string, unknown>
required
Provider credentials (API keys, tokens).
listEvents()
const response = await revstack . admin . integrations . listEvents (
integrationId ,
params
);
List webhook events received by an integration. Useful for debugging.
The integration to query events for.
Filter by processing status: ok, error, skipped.
Maximum records to return.
Number of records to skip.
listMetrics()
const response = await revstack . admin . integrations . listMetrics (
integrationId ,
params
);
List hourly aggregated metrics for an integration.
The integration to query metrics for.
ISO 8601 start date for the time range.
ISO 8601 end date for the time range.
Maximum records to return.
Number of records to skip.
admin.environments
create()
const environment = await revstack . admin . environments . create ( params );
params
CreateEnvironmentParams
required
Environment name (e.g. production, staging).
Auth provider: supabase, firebase, auth0, custom.
JWT signing algorithm: RS256, HS256, etc.
JWT audience (aud claim).
JWT secret (for HMAC algorithms).
JWKS endpoint URI (for RSA/ECDSA algorithms).
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.
The environment whose keys to rotate.
Example:
const { apiKeyPublic , apiKeySecret } =
await revstack . admin . environments . rotateKeys ( "env_prod" );
console . log ( "New keys generated:" );
console . log ( `Public: ${ apiKeyPublic } ` );
console . log ( `Secret: ${ apiKeySecret } ` );