Skip to content

MngGetSessions

Description: Lists platform session metadata held in the SessionGuard cache. By default, a staff member sees sessions owned by that staff identity, including its staff roles. A super admin can request another owner or all owners. Use category to separate ordinary sessions from API tokens and state to select active or historical records. Both filters are applied before pagination.

By default, the list includes all retained categories and states for compatibility. The current field marks the session used for this request. The API reads in-memory metadata indexes; it does not query SQLite. Staff owner selectors aggregate role types for the same manager ID, so a manager's sessions remain together if the manager role changes.

Inactive history is retained for 30 days, then physically removed from the SessionGuard cache and SQLite store. A revoked record is purged when it is more than 30 days past revoked_at; an unrevoked expired record is purged when it is more than 30 days past expires_at. Cleanup runs during startup before records are loaded and hourly in the background, including when the server is otherwise idle. The comparison is strict: a record exactly 30 days old remains until a later cleanup pass. Active sessions are not purged due to age, and an active non-expiring affiliate_api credential is retained.

After purging, the record no longer appears in this list. A valid MngRevokeSession request for its old sid returns SESSION_NOT_FOUND. A purged SID is not restored or re-created from the token and cannot authorize subsequent platform requests. Retention only removes inactive history: it does not extend token expiry or make an expired or revoked token valid again. The 30-day policy is fixed and has no configuration setting.

Access Control

🛡️ Access Level Required: SESSION_MANAGER, SESSION_ADMIN, SESSION_DEALER, SESSION_CRM_MANAGER, or SESSION_CRM_ADMIN with an ordinary staff session or a manager API token sent over TCP. The API token acts as its owner for the same manager ownership and super-admin checks.

Request Parameters

Name Type Required Description
offset int No Zero-based row offset, 0..1,000,000. Default 0.
limit int No Page size, 1..1,000. Default 100.
category string No sessions, api_tokens, or all. Default all. sessions includes ordinary, guest, and impersonation sessions; api_tokens includes manager and affiliate API tokens.
state string No active, all, revoked, or expired. Default all. active selects non-revoked sessions whose expiry is in the future (or has no expiry); revoked selects revoked rows; expired selects non-revoked rows whose expiry has passed.
owner_type int No Owner session type. Must be supplied together with owner_id. Supported values: 0 account, 1 manager, 2 dealer, 3 admin, 9 customer, 10 CRM manager, 11 CRM admin, 12 affiliate. -1 means all owner types and is valid only with owner_id: 0 for a super admin.
owner_id int No Owner ID. Must be supplied together with owner_type; must be positive for a specific owner, or 0 for the all-owner selector.

Without owner fields, the method lists the caller's own staff sessions. Supplying a specific owner is permitted for that same owner or a super admin. Staff owner types 1, 2, 3, 10, and 11 for the same owner_id select the same manager's records. Only a super admin can use owner_type: -1, owner_id: 0.

Request Example

{
  "command": "MngGetSessions",
  "extID": "request-1",
  "__token": "<compact Ed25519 manager API JWT>",
  "data": { "offset": 0, "limit": 100, "category": "api_tokens", "state": "active" }
}

Response Parameters

Field Type Description
rows array Session metadata rows, ordered newest first.
offset int Applied offset.
limit int Applied page size.
rows[].sid string Session UUIDv4.
rows[].kind string session, guest, impersonation, manager_api, or affiliate_api. Guest rows represent guest account sessions.
rows[].name string Session display name; empty when none was assigned.
rows[].owner_type int Principal type, using the values above.
rows[].owner_id int Principal ID.
rows[].login int Account login; 0 when the owner is not an account.
rows[].group string Group captured for the session; may be empty.
rows[].brand string Brand captured for the session; may be empty.
rows[].created_at int64 Issuance time, Unix seconds.
rows[].expires_at int64 Expiry time, Unix seconds; 0 only for an expiry-free affiliate API credential.
rows[].revoked_at int64 Revocation time, Unix seconds; 0 if not revoked.
rows[].revocation_reason string Revocation reason; empty if not revoked.
rows[].current bool true when this row is the caller's current session.
rows[].ip string Server-observed peer IP; empty if unavailable or not recorded. HTTP uses the configured trusted-proxy resolution; TCP/WebSocket uses the socket peer.
rows[].country string ISO 3166-1 alpha-2 country code from local IP geolocation, or empty if unavailable.
rows[].device string Advisory device label; empty if unavailable. TCP values are supplied through client_info.name and platform.
rows[].user_agent string HTTP User-Agent or advisory TCP client label/version; empty if unavailable.
rows[].transport string http, tcp, or ws; empty for legacy records or when unknown.
rows[].last_seen_at int64 Unix seconds of the latest authenticated activity; 0 when there is no observation yet, including newly issued API tokens before first use.
rows[].owner_name string Current display name for the owner, or empty when it cannot be resolved.
rows[].command_scope string manager for manager-permission API tokens; commands for explicitly restricted API tokens; empty for ordinary sessions or legacy records.
rows[].commands array of strings Explicit allowed command names for a token in commands scope; empty for manager scope, ordinary sessions, or legacy records.

Response Example

{
  "rows": [
    {
      "sid": "5f1d8a84-21f5-4e63-9be1-84a0f319b902",
      "kind": "manager_api",
      "name": "Nightly reconciliation",
      "owner_type": 1,
      "owner_id": 1001,
      "login": 0,
      "group": "",
      "brand": "ALFA",
      "created_at": 1793262000,
      "expires_at": 1793348400,
      "revoked_at": 0,
      "revocation_reason": "",
      "current": true,
      "ip": "203.0.113.24",
      "country": "CY",
      "device": "IonTrader · macOS",
      "user_agent": "Mozilla/5.0",
      "transport": "tcp",
      "last_seen_at": 1793262300,
      "owner_name": "Alice Smith",
      "command_scope": "manager",
      "commands": []
    }
  ],
  "offset": 0,
  "limit": 100
}

Errors

Status Error Description
400 INVALID_DATA Invalid pagination, category/state value, or incomplete/invalid owner selector.
403 PERMISSION_DENIED Caller lacks access to the requested owner scope, or supplied an explicit API command scope that does not include MngGetSessions.
503 SESSION_GUARD_UNAVAILABLE SessionGuard is not initialized or has become unavailable after a queued persistence failure.