Skip to content

SdkSession

A fully-initialized SDK session with convenience methods for creating placement and entitlement controllers, updating user context, and accessing the underlying SDK instance.

This is the recommended entry point for headless (non-React) consumers.

const session = await initRevTurbine({
tenantId: 'tenant_abc',
apiKey: 'rt_live_xxx',
endpoint: 'https://api.revturbine.io',
user: { id: 'user_123', plan: { id: 'pro' } },
});
// Get a placement by slot ID
const banner = session.placement({ surfaceSlot: { id: 'upsell_banner' } });
const decision = await banner.load();
// Check an entitlement with auto-gate
const gate = session.entitlement({ handle: 'brand_kit', autoGate: true });
await gate.check();
// Update user context (works in any runtime mode)
session.identify('user_456', { plan: { id: 'enterprise' } });
session.setUserContext({ personalization: { company: 'Acme' } });

readonly sdk: RevTurbineCustomerSdk

The underlying SDK instance. Use for advanced/direct operations.


readonly theme: RevTurbineTheme

Resolved theme.

checkEntitlement(handle, context?): Promise<{ }>

One-shot entitlement check. For auto-gating or reactive updates, prefer entitlement which returns a full controller.

string

RevTurbineEntitlementContext

Promise<{ }>


entitlement(options): EntitlementGate

Create an EntitlementGate bound to this session’s SDK.

EntitlementGateOptions

EntitlementGate

const gate = session.entitlement({ handle: 'brand_kit', autoGate: true });
await gate.check();
if (gate.denied) { showGate(gate.gatedPlacement); }

fetchUserContext(userId): Promise<UserTargetingContext>

Fetch full user context from the server (server runtime mode).

string

Promise<UserTargetingContext>


getPlacement(config): Promise<{ } | null>

Get a raw placement output by request config (slot, entitlement, plan, or chained). Returns the full PlacementOutput or null.

RevTurbinePlacementRequestConfig

Promise<{ } | null>


getPlacementBySlotId(slotId, options?): Promise<RevTurbinePlacementDecision | null>

One-shot: register a surface slot, fetch a decision, and return it.

For repeated use or interaction tracking, prefer placement which returns a full controller.

string

Omit<PlacementControllerOptions, "placement" | "surfaceSlot">

Promise<RevTurbinePlacementDecision | null>


getTrialStatus(): Promise<{ }>

Get the current trial status.

Promise<{ }>


getUsage(): RevTurbineUsageSnapshot

Get a snapshot of current usage balances.

RevTurbineUsageSnapshot


getUserContext(): object

Get the current resolved user context (includes tenant_id, user_id).

object


identify(userId, contextOrTraits?): void

Identify a user and optionally set traits/context. Triggers segment re-evaluation and clears decision cache.

string

UserContextInput | SdkTraits

void


placement(options): PlacementController

Create a PlacementController bound to this session’s SDK.

PlacementControllerOptions

PlacementController

const banner = session.placement({ surfaceSlot: { id: 'upsell_banner' } });
await banner.load();
if (banner.visible) { renderBanner(banner.content); }

resetIdentity(): void

Reset to anonymous user state.

void


resetUserContext(): void

Hard-reset the user context to a blank slate (no anonymous inference) — removes every user-context value plus usage balances and clears the decision cache, interaction state, and impression history. Mostly for demo / fixture flows. See RevTurbineCustomerSdk.resetUserContext.

void


setUserContext(context): void

Merge fields into the current user context. Triggers segment re-evaluation.

RevTurbineUserContext

void


trackEvent(name, data?): Promise<void>

Track a custom event.

string

Record<string, JsonValue>

Promise<void>


updateUsage(balances): void

Update usage balances (e.g. after a meter event).

UsageBalances

void