> **Building with AI coding agents?** Install the authstack plugin with one command. This equips your agent with accurate Scalekit implementation patterns.
>
> **Recommended**:
> ```bash
> npx @scalekit-inc/cli setup
> ```
>
> Global:
> ```bash
> npm install -g @scalekit-inc/cli
> scalekit setup
> ```
>
> Supports Claude Code, Cursor, GitHub Copilot, Codex + skills for 40+ agents.
> Features: full-stack-auth, agent-auth, mcp-auth, modular-sso, modular-scim.
> [Full setup guide](https://docs.scalekit.com/dev-kit/build-with-ai/)

---

# Sessions

Validate tokens and manage user sessions
<div class="sdk-client-page">

Use the `session` client to inspect session metadata and revoke sessions when users sign out or you detect risk.

Typical flows: load a session by ID after authentication, list a user's sessions for a security UI, and revoke one session or all of a user's sessions on logout.

### getSession
<div class="sdk-method-section">
  
    
      

      Retrieves comprehensive metadata and status for a specific user session.

      
        The session identifier to retrieve (format: "ses_...")
      
      
        Session metadata including status, user, device, and location.
      

```typescript wrap showLineNumbers=false
const session = await scalekit.session.getSession('ses_123456');

console.log('Status:', session.status);
console.log('User:', session.userId);
console.log('Device:', session.deviceInfo);
console.log('Location:', session.geoLocation);
```

    
  
</div>

### getUserSessions
<div class="sdk-method-section">
  
    
      

      Runs `getUserSessions` and returns the result.

      
        Scalekit user ID (`usr_...`).
      
      
        Optional fields: `pageSize`, `pageToken`, `filter`, `status`, `startTime`, `endTime`.
      
      
        The response payload for this operation.
      

```typescript wrap showLineNumbers=false
// pageSize: Results per page (default 10, max 100)
// pageToken: Token for the next page
// filter: Scoped tool filter
// status: status
// startTime: start time
// endTime: end time
const response = await scalekit.session.getUserSessions('usr_123456', {
  filter: { status: ['active'] },
  pageSize: 20
});

console.log(`User has ${response.totalSize} active sessions`);
```

    
  
</div>

### revokeSession
<div class="sdk-method-section">
  
    
      

      Runs `revokeSession` and returns the result.

      
        Session ID.
      
      
        Empty on success.
      

```typescript wrap showLineNumbers=false
const response = await scalekit.session.revokeSession('ses_123456');
console.log('Session revoked at:', response.revokedAt);
```

    
  
</div>

### revokeAllUserSessions
<div class="sdk-method-section">
  
    
      

      Immediately invalidates all active sessions for a user across all devices and browsers.

      
        The user identifier whose sessions should be revoked.
      
      
        Empty on success.
      

```typescript wrap showLineNumbers=false
const response = await scalekit.session.revokeAllUserSessions('usr_123456');

console.log(`Revoked ${response.totalCount} sessions`);
```

    
  
</div>

</div>


---

## More Scalekit documentation

| Resource | What it contains | When to use it |
|----------|-----------------|----------------|
| [/llms.txt](/llms.txt) | Structured index with routing hints per product area | Start here — find which documentation set covers your topic before loading full content |
| [/llms-full.txt](/llms-full.txt) | Complete documentation for all Scalekit products in one file | Use when you need exhaustive context across multiple products or when the topic spans several areas |
| [sitemap-0.xml](https://docs.scalekit.com/sitemap-0.xml) | Full URL list of every documentation page | Use to discover specific page URLs you can fetch for targeted, page-level answers |
