Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Organization session policy

Override application-level session timeouts for specific organizations with custom absolute and idle session policies

By default, all organizations inherit the session policy configured at the application level — covering absolute session duration and idle timeout. When an enterprise customer requires stricter or different session controls than your application defaults, you can set a custom session policy on a per-organization basis.

Scalekit always enforces the stricter of the two (application vs. organization) at session creation time, so organization policies can only tighten — not relax — your application-level defaults.

Organization-level session policies are controlled by the session_policy feature flag. Enable it on the organization before applying a custom policy.

await scalekit.organization.updateOrganizationSettings('org_12345', {
features: [{ name: 'session_policy', enabled: true }],
});
FieldDescription
policySourceAPPLICATION (inherit defaults) or CUSTOM (use per-org values)
absoluteSessionTimeoutMaximum session lifetime regardless of activity
absoluteSessionTimeoutUnitUnit for absolute timeout: MINUTES, HOURS, or DAYS
idleSessionTimeoutEnabledWhether idle timeout is active for this organization
idleSessionTimeoutTime after which an idle session expires
idleSessionTimeoutUnitUnit for idle timeout: MINUTES, HOURS, or DAYS

Retrieve the active session policy for an organization to display it in your settings UI or audit the current configuration.

const policy = await scalekit.organization.getOrganizationSessionPolicy('org_12345');
// policySource: 1 = APPLICATION (inheriting defaults), 2 = CUSTOM (org-specific values active)
console.log('Policy source:', policy.policySource);
console.log('Absolute timeout (minutes):', policy.absoluteSessionTimeout);
console.log('Idle timeout enabled:', policy.idleSessionTimeoutEnabled);

Apply a custom policy when an organization requires different session durations than your application defaults.

const updated = await scalekit.organization.updateOrganizationSessionPolicy('org_12345', {
policySource: 'CUSTOM',
absoluteSessionTimeout: 480,
absoluteSessionTimeoutUnit: 'MINUTES',
idleSessionTimeoutEnabled: true,
idleSessionTimeout: 60,
idleSessionTimeoutUnit: 'MINUTES',
});
console.log('Policy updated:', updated.policySource);

Remove a custom policy and restore the organization to the application-level session settings.

await scalekit.organization.updateOrganizationSessionPolicy('org_12345', {
policySource: 'APPLICATION',
});