Listar Sesiones Activas
Devuelve la lista de sesiones activas del usuario autenticado, ordenadas por fecha de creación (más nuevas primero).
GET
/auth/sessionsLista sesiones activas del usuario
📤 Respuesta
{
"code": 1018,
"message": "PIN status retrieved successfully.",
"data": {
"sessions": [
{
"sessionId": "uuid-session-id",
"device": "app",
"createdAt": "2025-01-20T14:45:00.000Z",
"lastSeenAt": "2025-01-20T15:10:00.000Z",
"expiresAt": "2025-02-19T14:45:00.000Z",
"metadata": {
"userAgent": "string",
"ip": "string",
"location": "string"
}
}
],
"total": 1
}
}Headers​
| Header | Value |
|---|---|
| Authorization | Bearer <JWT> |
Body​
Este endpoint no requiere body.
Response (200)​
Sesiones listadas
code 1018 — Se devuelve la lista de sesiones activas y el total.
data​
| Campo | Tipo | Descripción |
|---|---|---|
| sessions | array | Lista de sesiones activas |
| total | number | Cantidad total de sesiones activas |
Item de sessions[]​
| Campo | Tipo | Descripción |
|---|---|---|
| sessionId | string | Identificador de la sesión |
| device | "app" | "web" | Tipo de dispositivo |
| createdAt | string | Timestamp ISO 8601 |
| lastSeenAt | string | Timestamp ISO 8601 |
| expiresAt | string | Timestamp ISO 8601 |
| metadata | object | null | Metadatos de la sesión (si existen) |
metadata (cuando existe)​
| Campo | Tipo | Descripción |
|---|---|---|
| userAgent | string | User-Agent (si existe) |
| ip | string | IP (si existe) |
| location | string | Ubicación (si existe) |
Ejemplo:
{
"code": 1018,
"message": "PIN status retrieved successfully.",
"data": {
"sessions": [
{
"sessionId": "uuid-session-id",
"device": "web",
"createdAt": "2025-01-20T14:45:00.000Z",
"lastSeenAt": "2025-01-20T15:10:00.000Z",
"expiresAt": "2025-02-19T14:45:00.000Z",
"metadata": {
"userAgent": "Mozilla/5.0 ...",
"ip": "203.0.113.10",
"location": "Buenos Aires, AR"
}
}
],
"total": 1
}
}
Errores​
No autorizado
HTTP 401 — Token JWT inválido, expirado o ausente.
{
"statusCode": 401,
"message": "Unauthorized"
}
Error interno
HTTP 500 — code 5001.
{
"code": 5001,
"message": "Failed to save user to the database.",
"details": "..."
}
Ejemplo (cURL)​
curl -X GET 'https://api.swapbits.co/auth/sessions' \
-H 'Authorization: Bearer YOUR_JWT_TOKEN'
⚡ Quick Test​
GET
https://api.swapbits.co/auth/sessionscurl -X GET 'https://api.swapbits.co/auth/sessions' \
-H 'Content-Type: application/json'
---
## Enlaces Relacionados
* [Revocar Sesión](./sessions-revoke.md) — DELETE /auth/sessions/:sid
* [Revocar Todas las Sesiones (Excepto la Actual)](./sessions-revoke-all.md) — POST /auth/sessions/revoke-all
* [Estado de Sesión PIN](./pin-session-status.md) — GET /auth/pin/session/status