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.
Example
Section titled “Example”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 IDconst banner = session.placement({ surfaceSlot: { id: 'upsell_banner' } });const decision = await banner.load();
// Check an entitlement with auto-gateconst 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' } });Properties
Section titled “Properties”
readonlysdk:RevTurbineCustomerSdk
The underlying SDK instance. Use for advanced/direct operations.
readonlytheme:RevTurbineTheme
Resolved theme.
Methods
Section titled “Methods”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.
Parameters
Section titled “Parameters”handle
Section titled “handle”string
context?
Section titled “context?”RevTurbineEntitlementContext
Returns
Section titled “Returns”Promise<{ }>
checkEntitlement()
Section titled “checkEntitlement()”checkEntitlement(
handle,context?):Promise<{ }>
One-shot entitlement check. For auto-gating or reactive updates, prefer entitlement which returns a full controller.
Parameters
Section titled “Parameters”handle
Section titled “handle”string
context?
Section titled “context?”RevTurbineEntitlementContext
Returns
Section titled “Returns”Promise<{ }>
entitlement()
Section titled “entitlement()”entitlement(
options):EntitlementGate
Create an EntitlementGate bound to this session’s SDK.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”EntitlementGate
Example
Section titled “Example”const gate = session.entitlement({ handle: 'brand_kit', autoGate: true });await gate.check();if (gate.denied) { showGate(gate.gatedPlacement); }fetchUserContext()
Section titled “fetchUserContext()”fetchUserContext(
userId):Promise<UserTargetingContext>
Fetch full user context from the server (server runtime mode).
Parameters
Section titled “Parameters”userId
Section titled “userId”string
Returns
Section titled “Returns”Promise<UserTargetingContext>
flushEvents()
Section titled “flushEvents()”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.
Returns
Section titled “Returns”Promise<void>
getPlacement()
Section titled “getPlacement()”getPlacement(
config):Promise<{ } |null>
Get a raw placement output by request config (slot, entitlement, plan, or chained).
Returns the full PlacementOutput or null.
Parameters
Section titled “Parameters”config
Section titled “config”RevTurbinePlacementRequestConfig
Returns
Section titled “Returns”Promise<{ } | null>
getPlacementBySlotId()
Section titled “getPlacementBySlotId()”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.
Parameters
Section titled “Parameters”slotId
Section titled “slotId”string
options?
Section titled “options?”Omit<PlacementControllerOptions, "placement" | "surfaceSlot">
Returns
Section titled “Returns”Promise<RevTurbinePlacementDecision | null>
getTrialStatus()
Section titled “getTrialStatus()”getTrialStatus():
Promise<{ }>
Get the current trial status.
Returns
Section titled “Returns”Promise<{ }>
getUsage()
Section titled “getUsage()”getUsage():
RevTurbineUsageSnapshot
Get a snapshot of current usage balances.
Returns
Section titled “Returns”getUserContext()
Section titled “getUserContext()”getUserContext():
object
Get the current resolved user context (includes tenant_id, user_id).
Returns
Section titled “Returns”object
identify()
Section titled “identify()”identify(
userId,contextOrTraits?):void
Identify a user and optionally set traits/context. Triggers segment re-evaluation and clears decision cache.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
contextOrTraits?
Section titled “contextOrTraits?”Exact<IdentifyContextInput, IdentifyContextInput>
Returns
Section titled “Returns”void
placement()
Section titled “placement()”placement(
options):PlacementController
Create a PlacementController bound to this session’s SDK.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”Example
Section titled “Example”const banner = session.placement({ surfaceSlot: { id: 'upsell_banner' } });await banner.load();if (banner.visible) { renderBanner(banner.content); }resetIdentity()
Section titled “resetIdentity()”resetIdentity():
void
Reset to anonymous user state.
Returns
Section titled “Returns”void
resetUserContext()
Section titled “resetUserContext()”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.
Returns
Section titled “Returns”void
setUserContext()
Section titled “setUserContext()”setUserContext(
context):void
Merge fields into the current user context. Triggers segment re-evaluation.
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”void
track()
Section titled “track()”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.
Parameters
Section titled “Parameters”string
Record<string, JsonValue>
Returns
Section titled “Returns”Promise<void>
trackEvent()
Section titled “trackEvent()”trackEvent(
name,data?):Promise<void>
Track a custom event.
Parameters
Section titled “Parameters”string
Record<string, JsonValue>
Returns
Section titled “Returns”Promise<void>
update()
Section titled “update()”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.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
updateUsage()
Section titled “updateUsage()”updateUsage(
balances):void
Update usage balances (e.g. after a meter event).
Parameters
Section titled “Parameters”balances
Section titled “balances”Returns
Section titled “Returns”void