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://edge.example.com',
user: { id: 'user_123', plan_handle: '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_handle: 'enterprise' });
session.setUserContext({ personalization: { company: 'Acme' } });

readonly sdk: RevTurbineCustomerSdk

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


readonly theme: RevTurbineTheme

Resolved theme.

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

The entitlement check as a can question — alias of checkEntitlement, promoted onto the session facade so session.can('batch_export') works without the session.sdk escape hatch (plan 179 Q-1/Q-3 ruling). Read .allowed for the verdict; an at-cap blocked limit resolves limited + allowed: false.

string

RevTurbineEntitlementContext

Promise<{ }>


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>


flushEvents(): Promise<void>

Flush buffered events immediately. Headless processes are often short-lived (scripts, jobs, edge handlers) — call this before exit so buffered track() events aren’t lost with the process.

Promise<void>


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

Exact<IdentifyContextInput, IdentifyContextInput>

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


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

Track an event — the advertised alias of trackEvent, first-class on the session facade so headless code carries the full telemetry surface (plan 179 ruling, Kent 2026-08-13). Powers analytics, frequency caps, attribution, and experiments.

string

Record<string, JsonValue>

Promise<void>


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

Track a custom event.

string

Record<string, JsonValue>

Promise<void>


update(patch): void

Patch the session-scoped user context — the whole-context-minus-id upsert (update({ plan: {...} }), update({ usage: {...} }), …). Alias of the SDK’s update(), promoted onto the session facade so the documented session.update() verb is real (plan 179 Q-1/Q-3 ruling). Unrecognized keys warn (prod-visible, once per session) and drop, exactly as on the SDK — plan 191 Q-5 made the warning prod-visible rather than dev-only, so this comment was stale in the direction that matters.

RevTurbineUpdateInput

void


updateUsage(balances): void

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

UsageBalances

void