White-label API: Active Employee Tracking Sessions
Build a current-session view for your company using the white-label API.
This guide is for the person connecting a company portal or integration. To review employees without building anything, use Team reports or Time Worked.
1. Have the company’s API access configured
A WorkPulse system administrator must enable the customer portal for the company and configure its allowed client origins or a private client key. The company also needs API Access. The signed-in user needs View Users or View All Captures for this endpoint.
Browser portals should use their approved origin. Private server integrations can send X-WorkPulse-Client-Key. Keep that key on your server; do not put it in a public browser bundle. The client setting identifies an allowed integration and does not replace the user’s login token.
2. Sign in through the white-label API
POST /api/white-label/v1/auth/login
Accept: application/json
Content-Type: application/json
X-WorkPulse-Client-Key: YOUR_PRIVATE_CLIENT_KEY
{
"email": "manager@example.test",
"password": "YOUR_PASSWORD",
"tenant_id": "YOUR_COMPANY_ID"
}The company ID is optional at login when only one eligible company is available. If the response contains requires_tenant_selection: true, use its temp_token as the bearer token for POST /api/white-label/v1/auth/select-tenant, with the chosen tenant_id. Use the resulting company token for subsequent requests.
Use the same approved client origin or private client key throughout this flow. A temporary selection token is not a company API token.
3. Request the open sessions
GET /api/white-label/v1/active-sessions
Accept: application/json
Authorization: Bearer YOUR_COMPANY_TOKEN
X-WorkPulse-Client-Key: YOUR_PRIVATE_CLIENT_KEYThe response contains generated_at, active_sessions_count and an active_sessions array. Each entry includes:
- The session ID and the employee’s ID, name and email.
- The associated project, team and session type, where available.
started_atandduration_seconds.last_activity_at, idle prompt and expiry timestamps, and accumulated idle seconds.is_on_breakandbreak_started_at.
“Active” means the session has no end time. It does not prove the employee is currently typing, connected or productive. Open break sessions are included and marked as breaks. Check break and last-activity fields before presenting a “working now” label.
duration_seconds is elapsed time since the session started, not approved payable time. Some related objects or timestamps can be null; handle those without breaking the screen. An empty array means no open sessions were returned for this company.
4. Refresh and handle errors clearly
A refresh every 30–60 seconds is usually sufficient for a status screen. Keep within the company’s shared API request allowance and show when the data was last refreshed. If a refresh fails, label the existing data as out of date.
- 401: sign in again with a valid user token.
- 403: check company access, customer portal enablement, client approval and user permissions.
- 422: check the validation errors in the response.
- 429: wait before retrying; reduce the refresh rate if needed.
For historical totals or payroll, use the appropriate reports rather than adding up open-session durations.
Was this article helpful?