GET /api/sessions
- List all user sessionsGET /api/sessions/active
- List active sessionsGET /api/sessions/{uuid}
- Get session detailsPATCH /api/sessions/{uuid}/renew
- Renew sessionDELETE /api/sessions/{uuid}/end
- End sessionPATCH /api/sessions/{uuid}/block
- Block sessionPATCH /api/sessions/{uuid}/unblock
- Unblock sessionPOST /api/sessions/signout
- Sign out from all sessions
Retrieve all sessions for the authenticated user.
GET /api/sessions
curl -X GET "http://your-app.com/api/sessions" \
-H "Authorization: Bearer your-token" \
-H "Accept: application/json"
const response = await axios.get('/api/sessions', {
headers: {
'Authorization': `Bearer ${token}`,
'Accept': 'application/json'
}
});
$response = $client->get('/api/sessions');
$sessions = json_decode($response->getBody(), true);
{
"data": [
{
"uuid": "98765432-fedc-ba98-7654-321fedcba987",
"ip": "192.168.1.1",
"location": {
"ip": "192.168.1.1",
"hostname": "host.example.com",
"country": "ES",
"region": "Madrid",
"city": "Madrid",
"postal": "28001",
"latitude": "40.4168",
"longitude": "-3.7038",
"timezone": "Europe/Madrid",
"label": "28001 Madrid, Madrid, ES"
},
"status": "active",
"last_activity_at": "2024-10-27T15:45:00Z",
"started_at": "2024-10-27T14:30:00Z",
"finished_at": null,
"device": {
"uuid": "01234567-89ab-cdef-0123-456789abcdef",
"status": "verified",
"browser": {
"name": "Chrome",
"version": {
"major": "118",
"minor": "0",
"patch": "0"
}
}
}
}
]
}
Retrieve only active sessions for the authenticated user.
GET /api/sessions/active
curl -X GET "http://your-app.com/api/sessions/active" \
-H "Authorization: Bearer your-token" \
-H "Accept: application/json"
const response = await axios.get('/api/sessions/active', {
headers: {
'Authorization': `Bearer ${token}`,
'Accept': 'application/json'
}
});
$response = $client->get('/api/sessions/active');
{
"data": [
{
"uuid": "98765432-fedc-ba98-7654-321fedcba987",
"ip": "192.168.1.1",
"location": {
"ip": "192.168.1.1",
"hostname": "host.example.com",
"country": "ES",
"region": "Madrid",
"city": "Madrid",
"postal": "28001",
"latitude": "40.4168",
"longitude": "-3.7038",
"timezone": "Europe/Madrid",
"label": "28001 Madrid, Madrid, ES"
},
"status": "active",
"last_activity_at": "2024-10-27T15:45:00Z",
"started_at": "2024-10-27T14:30:00Z",
"finished_at": null,
"device": {
"uuid": "01234567-89ab-cdef-0123-456789abcdef",
"status": "verified"
}
}
]
}
Retrieve detailed information about a specific session.
GET /api/sessions/{uuid}
curl -X GET "http://your-app.com/api/sessions/98765432-fedc-ba98-7654-321fedcba987" \
-H "Authorization: Bearer your-token" \
-H "Accept: application/json"
const response = await axios.get(`/api/sessions/${sessionUuid}`, {
headers: {
'Authorization': `Bearer ${token}`,
'Accept': 'application/json'
}
});
$response = $client->get("/api/sessions/{$sessionUuid}");
{
"data": {
"uuid": "98765432-fedc-ba98-7654-321fedcba987",
"ip": "192.168.1.1",
"location": {
"ip": "192.168.1.1",
"hostname": "host.example.com",
"country": "ES",
"region": "Madrid",
"city": "Madrid",
"postal": "28001",
"latitude": "40.4168",
"longitude": "-3.7038",
"timezone": "Europe/Madrid",
"label": "28001 Madrid, Madrid, ES"
},
"status": "active",
"last_activity_at": "2024-10-27T15:45:00Z",
"started_at": "2024-10-27T14:30:00Z",
"finished_at": null,
"device": {
"uuid": "01234567-89ab-cdef-0123-456789abcdef",
"status": "verified",
"browser": {
"name": "Chrome",
"version": {
"major": "118",
"minor": "0",
"patch": "0"
}
}
},
"metadata": {}
}
}
Update the last activity timestamp of a session.
PATCH /api/sessions/{uuid}/renew
curl -X PATCH "http://your-app.com/api/sessions/98765432-fedc-ba98-7654-321fedcba987/renew" \
-H "Authorization: Bearer your-token" \
-H "Accept: application/json"
const response = await axios.patch(`/api/sessions/${sessionUuid}/renew`, {}, {
headers: {
'Authorization': `Bearer ${token}`,
'Accept': 'application/json'
}
});
{
"message": "Session renewed successfully"
}
Control session access through blocking/unblocking.
PATCH /api/sessions/{uuid}/block
PATCH /api/sessions/{uuid}/unblock
# Block session
curl -X PATCH "http://your-app.com/api/sessions/98765432-fedc-ba98-7654-321fedcba987/block" \
-H "Authorization: Bearer your-token" \
-H "Accept: application/json"
# Unblock session
curl -X PATCH "http://your-app.com/api/sessions/98765432-fedc-ba98-7654-321fedcba987/unblock" \
-H "Authorization: Bearer your-token" \
-H "Accept: application/json"
// Block session
const blockResponse = await axios.patch(`/api/sessions/${sessionUuid}/block`, {}, {
headers: {
'Authorization': `Bearer ${token}`,
'Accept': 'application/json'
}
});
// Unblock session
const unblockResponse = await axios.patch(`/api/sessions/${sessionUuid}/unblock`, {}, {
headers: {
'Authorization': `Bearer ${token}`,
'Accept': 'application/json'
}
});
// Block
{
"message": "Session blocked successfully"
}
// Unblock
{
"message": "Session unblocked successfully"
}
Terminate a specific session.
DELETE /api/sessions/{uuid}/end
curl -X DELETE "http://your-app.com/api/sessions/98765432-fedc-ba98-7654-321fedcba987/end" \
-H "Authorization: Bearer your-token" \
-H "Accept: application/json"
const response = await axios.delete(`/api/sessions/${sessionUuid}/end`, {
headers: {
'Authorization': `Bearer ${token}`,
'Accept': 'application/json'
}
});
{
"message": "Session ended successfully"
}
End all active sessions for the current user.
POST /api/sessions/signout
curl -X POST "http://your-app.com/api/sessions/signout" \
-H "Authorization: Bearer your-token" \
-H "Accept: application/json"
const response = await axios.post('/api/sessions/signout', {}, {
headers: {
'Authorization': `Bearer ${token}`,
'Accept': 'application/json'
}
});
{
"message": "Signout successful"
}
All endpoints may return these common errors:
{
"message": "Session locked"
}
{
"message": "Too Many Attempts.",
"retry_after": 60
}
async function manageSessionSecurity(sessionUuid) {
try {
// Get session details
const sessionResponse = await axios.get(`/api/sessions/${sessionUuid}`);
const session = sessionResponse.data.data;
// Check location
if (isLocationSuspicious(session.location)) {
// Block session
await axios.patch(`/api/sessions/${sessionUuid}/block`);
return;
}
// Check inactivity
const inactivityThreshold = 30 * 60 * 1000; // 30 minutes
const lastActivity = new Date(session.last_activity_at);
if (Date.now() - lastActivity > inactivityThreshold) {
// End session
await axios.delete(`/api/sessions/${sessionUuid}/end`);
return;
}
// Renew active session
await axios.patch(`/api/sessions/${sessionUuid}/renew`);
} catch (error) {
handleApiError(error);
}
}
- Learn about Device Management API
- Explore 2FA API
- Review Events System