Playground Session Management
Managing sessions in the FinHub API Playground Environment
Session Management in the Playground
This guide explains how to manage sessions when working with the FinHub API in the Playground environment.
Session Tokens Overview
When a user logs in through the authentication endpoints, the system creates a session and returns several tokens:
Key Session Components
Component | Description | Usage |
---|---|---|
userSessionToken | JWT token for user session validation | Used for session validation and contains user identity claims |
customerId | Unique identifier for the customer | Reference in customer-related operations |
tenantId | Identifier for the tenant | Used for multi-tenant operations |
Activity Tracking Headers
Every API request in the FinHub platform must include two important headers for session and activity tracking:
- X-Activity-ID: A UUID that identifies a specific user activity or flow
- X-Tenant-ID: The tenant identifier for multi-tenant operations
Activity ID Generation
The Activity ID should be a UUID (v4) generated for each distinct user activity or flow. For example:
Including Session Headers in Requests
All API requests must include the session token and tracking headers:
Session Lifecycle
Session Creation
A session is created when a user successfully authenticates through the login endpoint. The session includes:
- A user session token (JWT)
- An internally managed access token (not exposed to clients)
- User identity information
Session Maintenance
To maintain an active session:
- Include the user session token in all API requests
- Use consistent activity IDs for related operations within a flow
- Re-authenticate before the token expires (based on
expires_in
value)
Session Expiration
Sessions expire after the time specified in the expires_in
parameter (in seconds). When a session expires:
- API requests will return a
401 Unauthorized
error - You must authenticate again to obtain a new session token
- A new activity ID should be generated for the new session
Session Termination
To explicitly terminate a session, call the logout endpoint:
Best Practices for Session Management
- Generate unique activity IDs for each user flow or journey
- Store session tokens securely using appropriate storage mechanisms
- Implement token refresh logic to handle token expiration
- Clear session data after logout or session expiration
- Handle authentication errors gracefully with user-friendly messages
Moving to Integration
When you’re ready to move from the Playground to the Integration environment, you’ll need to follow more formal session management practices. See the Integration Session Management guide for details.
Important Notes
- In the Playground environment, session timeouts are typically longer than in production to facilitate development and testing
- For security reasons, the raw access token is not exposed to clients and is managed internally by the system
- Detailed session management is part of the formal integration process and will be covered in depth during that phase
For questions about session management in the Playground environment, contact our developer support team at developer-support@finhub.cloud.