portal

List portal sessions

Changed on

List the end users holding a revocable session on a portal, with each end user's sessions.

Unreleased and subject to change without notice.

A session is revocable until it expires or is revoked. That includes sessions whose portal URL was created but not opened yet. Pass an end user's externalId to portal.revokeSession to end their sessions.

Required Permissions

Your root key must have one of:

  • portal.*.create_portal_session (for any portal in the workspace)
  • portal.<portal_id>.create_portal_session (for a specific portal)

It also accepts unkey:v1:<workspace_id>:projects/<project_id>/portals/<portal_id>/sessions/* with #read or #write. Reading the portal itself is not enough.

Without the permission this returns 404, not 403.

post/v2/portal.listSessions

Request

  • Base URL
    https://api.unkey.com
  • URL
    https://api.unkey.com/v2/portal.listSessions
  • Auth
    HTTP bearer

Request body

portalstring required

Identifies a resource by either its unique ID or its slug. Accepts a prefixed ID (such as 'proj_' or 'app_') or a slug.

limitinteger

Maximum number of end users to return per request.

cursorstring

Pagination cursor from a previous response to fetch the next page. Use when hasMore: true in the previous response.

searchstring

Returns only end users whose externalId starts with this string. Matching is case-sensitive, and % and _ match literally.

Example request

{
  "portal": "proj_1234abcd",
  "cursor": "user_123",
  "search": "user_"
}

Response

One page of end users with revocable sessions.

Example response

{
  "meta": {
    "requestId": "req_123"
  },
  "data": [
    {
      "externalId": "user_123",
      "sessions": [
        {
          "id": "ps_1234abcd",
          "status": "active",
          "createdAt": 1704067200000,
          "expiresAt": 1704153600000,
          "scopes": [
            "keys:read"
          ]
        }
      ]
    }
  ],
  "pagination": {
    "cursor": "eyJrZXkiOiJrZXlfMTIzNCIsInRzIjoxNjk5Mzc4ODAwfQ==",
    "hasMore": true
  }
}

Changes