Skip to main content
Manage active sessions for the authenticated user. Each login creates a new session. Sessions track the user agent and IP address for security visibility.

List Sessions

GET /api/v1/users/me/sessions
Requires a valid Bearer token.
Returns all active (non-expired) sessions for the authenticated user, sorted by most recently used.

Response

sessions
array
Array of session objects.
total
number
Total number of active sessions.
{
  "sessions": [
    {
      "id": "ses_abc123def456",
      "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)",
      "ipAddress": "192.168.1.1",
      "lastUsedAt": "2024-01-21T09:00:00Z",
      "expiresAt": "2024-01-28T09:00:00Z",
      "createdAt": "2024-01-21T08:00:00Z",
      "isCurrent": true
    },
    {
      "id": "ses_xyz789ghi012",
      "userAgent": "BunShip-CLI/1.0",
      "ipAddress": "10.0.0.5",
      "lastUsedAt": "2024-01-20T15:00:00Z",
      "expiresAt": "2024-01-27T15:00:00Z",
      "createdAt": "2024-01-20T12:00:00Z",
      "isCurrent": false
    }
  ],
  "total": 2
}

Example

curl https://api.bunship.com/api/v1/users/me/sessions \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."

Revoke Session

DELETE /api/v1/users/me/sessions/{sessionId}
Requires a valid Bearer token.
Revokes a specific session, logging out that device. You cannot revoke the current session — use the logout endpoint instead.

Path Parameters

sessionId
string
required
The ID of the session to revoke.

Response

message
string
Confirmation message.
{
  "message": "Session revoked successfully"
}

Errors

StatusCodeDescription
400VALIDATION_ERRORCannot revoke the current session
401AUTHENTICATION_ERRORMissing or invalid Bearer token
404NOT_FOUNDSession not found or does not belong to this user

Example

curl -X DELETE https://api.bunship.com/api/v1/users/me/sessions/ses_xyz789ghi012 \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."