Connected Devices API
Introduction to Connected Devices API
Welcome to SMSGatewayCenter's Connected Devices API! This powerful Security API allows you to manage your active sessions and connected devices programmatically. View all active sessions, logout specific devices, and secure your account by logging out all other devices. Our RESTful endpoints support POST and GET methods over HTTP with full VAPT compliance for secure integration.
About Connected Devices API
The Connected Devices API enables you to:
- View all active sessions - List all devices currently logged into your account
- Monitor device information - See device name, browser, OS, location, IP address, and login time
- Track last activity - View when each device was last active
- Logout specific device - Terminate a session on a particular device
- Logout all other devices - Secure your account by logging out all devices except the current one
- Identify current session - Know which device you're currently using
- Security monitoring - Detect unauthorized access and manage account security
All operations include comprehensive VAPT security measures including session validation, authorization checks, and secure session management.
Security Features
- Session Validation: All session operations verify ownership before execution
- Authorization Checks: Only account owner can view and manage their sessions
- Device Tracking: Complete device information including browser, OS, and location
- Activity Monitoring: Track last activity time for each session
- Secure Logout: Safely terminate sessions without affecting current device
- IP Address Tracking: Monitor IP addresses for security auditing
Get Connected Devices
Retrieve a list of all active sessions and connected devices for your account. This includes device information, location, login time, and last activity.
API Endpoint
https://unify.smsgateway.center/SMSApi/security/connectedDevicesHTTP Method
POST GET
| Key | Value | Description |
|---|---|---|
| Login Credentials (Required) | ||
| Authenticate your API request using userid-password or apiKey—choose one method. | ||
| userid | Your Registered Username | Your registered username; use if apiKey isn't provided. Signup for User ID |
| password | Your Password | URL-encoded password (for special characters); use if apiKey isn't provided. Signup for API Key |
| Header (optional) Parameters | ||
| apiKey | Your unique apiKey | apiKey needs to be sent as HTTP header when you are not using userid-password method. You can avail this from your user control panel and use instead of userid-password HTTP Request parameter. Please do not disclose this to anyone. |
| Parameter | Type | Required | Description |
|---|---|---|---|
output | String | Optional | Response format. Use json for JSON response (recommended) |
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://unify.smsgateway.center/SMSApi/security/connectedDevices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array(
'userid' => 'YourUsername',
'password' => 'YourPassword',
'output' => 'json'
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
{
"response": {
"api": "security",
"action": "connectedDevices",
"status": "success",
"msg": "Connected devices retrieved successfully",
"code": 200,
"count": 2,
"sessions": [
{
"sessionId": "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz",
"sessionToken": "xyz789abc123def456ghi789jkl012mno345pqr678stu901vwx234",
"deviceName": "Chrome on Windows",
"deviceType": "Desktop",
"platform": "Desktop",
"os": "Windows",
"browser": "Chrome",
"location": "Mumbai, Maharashtra, India",
"ipAddress": "192.168.1.1",
"loginMethod": "UI",
"loginTime": "2025-01-15 10:30:00",
"lastActivity": "2025-01-15 11:45:00",
"lastActivityTimestamp": 1705303500000,
"timeAgo": "15 minutes ago",
"isCurrentSession": false
},
{
"sessionId": "current123session456id789abc012def345ghi678jkl901mno234",
"sessionToken": "current789token123abc456def789ghi012jkl345mno678pqr901stu234",
"deviceName": "Safari on macOS",
"deviceType": "Desktop",
"platform": "Desktop",
"os": "macOS",
"browser": "Safari",
"location": "Delhi, Delhi, India",
"ipAddress": "192.168.1.100",
"loginMethod": "UI",
"loginTime": "2025-01-15 09:00:00",
"lastActivity": "2025-01-15 12:00:00",
"lastActivityTimestamp": 1705312800000,
"timeAgo": "Just now",
"isCurrentSession": true
}
]
}
}
Logout Specific Device
Terminate a session on a specific device by providing either the session ID or session token. This is useful for logging out a device you no longer have access to or suspect is compromised.
API Endpoint
https://unify.smsgateway.center/SMSApi/security/logoutDeviceHTTP Method
POST
| Key | Value | Description |
|---|---|---|
| Login Credentials (Required) | ||
| Authenticate your API request using userid-password or apiKey—choose one method. | ||
| userid | Your Registered Username | Your registered username; use if apiKey isn't provided. Signup for User ID |
| password | Your Password | URL-encoded password (for special characters); use if apiKey isn't provided. Signup for API Key |
| Header (optional) Parameters | ||
| apiKey | Your unique apiKey | apiKey needs to be sent as HTTP header when you are not using userid-password method. You can avail this from your user control panel and use instead of userid-password HTTP Request parameter. Please do not disclose this to anyone. |
| Parameter | Type | Required | Description |
|---|---|---|---|
sessionId | String | Conditional | Session ID of the device to logout. Required if sessionToken is not provided |
sessionToken | String | Conditional | Session token of the device to logout. Required if sessionId is not provided |
output | String | Optional | Response format. Use json for JSON response (recommended) |
Note: You must provide either sessionId or sessionToken, but not both.
curl --location 'https://unify.smsgateway.center/SMSApi/security/logoutDevice' \
--form 'userid="YourUsername"' \
--form 'password="YourPassword"' \
--form 'sessionId="abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"' \
--form 'output="json"'curl --location 'https://unify.smsgateway.center/SMSApi/security/logoutDevice' \
--form 'userid="YourUsername"' \
--form 'password="YourPassword"' \
--form 'sessionToken="xyz789abc123def456ghi789jkl012mno345pqr678stu901vwx234"' \
--form 'output="json"'{
"response": {
"api": "security",
"action": "logoutDevice",
"status": "success",
"msg": "Device logged out successfully",
"code": 200,
"count": 1,
"logout": {
"sessionId": "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz",
"deviceName": "Chrome on Windows",
"loggedOut": true,
"timestamp": "2025-01-15T12:00:00+00:00"
}
}
}
Logout All Other Devices
Securely logout all devices except the current one. This is useful when you want to ensure only your current device has access to your account, or if you suspect unauthorized access.
API Endpoint
https://unify.smsgateway.center/SMSApi/security/logoutAllOtherDevicesHTTP Method
POST
| Key | Value | Description |
|---|---|---|
| Login Credentials (Required) | ||
| Authenticate your API request using userid-password or apiKey—choose one method. | ||
| userid | Your Registered Username | Your registered username; use if apiKey isn't provided. Signup for User ID |
| password | Your Password | URL-encoded password (for special characters); use if apiKey isn't provided. Signup for API Key |
| Header (optional) Parameters | ||
| apiKey | Your unique apiKey | apiKey needs to be sent as HTTP header when you are not using userid-password method. You can avail this from your user control panel and use instead of userid-password HTTP Request parameter. Please do not disclose this to anyone. |
| Parameter | Type | Required | Description |
|---|---|---|---|
output | String | Optional | Response format. Use json for JSON response (recommended) |
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://unify.smsgateway.center/SMSApi/security/logoutAllOtherDevices",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => array(
'userid' => 'YourUsername',
'password' => 'YourPassword',
'output' => 'json'
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
{
"response": {
"api": "security",
"action": "logoutAllOtherDevices",
"status": "success",
"msg": "All other devices logged out successfully",
"code": 200,
"count": 1,
"logoutAll": {
"currentSessionId": "current123session456id789abc012def345ghi678jkl901mno234",
"devicesLoggedOut": 3,
"timestamp": "2025-01-15T12:00:00+00:00"
}
}
}
Response Fields Explained
Session Object Fields
| Field | Type | Description |
|---|---|---|
sessionId | String | Unique session identifier for the device |
sessionToken | String | Session token for authentication (can be used instead of sessionId) |
deviceName | String | Human-readable device name (e.g., "Chrome on Windows") |
deviceType | String | Type of device: Desktop, Mobile, Tablet |
platform | String | Platform category: Desktop, Mobile, Tablet |
os | String | Operating system (e.g., Windows, macOS, Linux, Android, iOS) |
browser | String | Browser name (e.g., Chrome, Safari, Firefox, Edge) |
location | String | Geographic location based on IP address (e.g., "Mumbai, Maharashtra, India") |
ipAddress | String | IP address of the device |
loginMethod | String | Method used to login: UI (web interface) or API |
loginTime | String | Date and time when the session was created (format: Y-m-d H:i:s) |
lastActivity | String | Date and time of last activity on this session (format: Y-m-d H:i:s) |
lastActivityTimestamp | Integer | Unix timestamp of last activity (milliseconds) |
timeAgo | String | Human-readable time since last activity (e.g., "15 minutes ago", "Just now") |
isCurrentSession | Boolean | True if this is the current session making the API call, false otherwise |
Error Codes
| Error Code | HTTP Status | Description |
|---|---|---|
200 | 200 | Success - Request completed successfully |
| Logout Device Errors (448-453) | ||
448 | 400 | Session ID or Session Token is required |
449 | 400 | Invalid session ID |
450 | 404 | Session not found |
451 | 403 | Unauthorized - Session doesn't belong to user |
452 | 500 | Failed to logout device |
453 | 500 | Error occurred while logging out device |
| Logout All Other Devices Errors (454-456) | ||
454 | 500 | Failed to logout other devices |
455 | 404 | No active sessions found |
456 | 500 | Error occurred while logging out other devices |
| General Errors | ||
500 | 500 | General error |
Integration Examples
Example 1: Display Connected Devices in Mobile App
// React Native / JavaScript example
async function getConnectedDevices() {
const formData = new FormData();
formData.append('userid', 'YourUsername');
formData.append('password', 'YourPassword');
formData.append('output', 'json');
try {
const response = await fetch('https://unify.smsgateway.center/SMSApi/security/connectedDevices', {
method: 'POST',
body: formData
});
const data = await response.json();
if (data.response.status === 'success') {
const sessions = data.response.sessions;
sessions.forEach(session => {
console.log(`Device: ${session.deviceName}`);
console.log(`Location: ${session.location}`);
console.log(`Last Activity: ${session.timeAgo}`);
console.log(`Current Session: ${session.isCurrentSession ? 'Yes' : 'No'}`);
console.log('---');
});
return sessions;
} else {
console.error(`Error: ${data.response.msg}`);
}
} catch (error) {
console.error('Network error:', error);
}
}
getConnectedDevices();Example 2: Logout Specific Device
import requests
def logout_device(session_id):
url = 'https://unify.smsgateway.center/SMSApi/security/logoutDevice'
data = {
'userid': 'YourUsername',
'password': 'YourPassword',
'sessionId': session_id,
'output': 'json'
}
response = requests.post(url, data=data)
result = response.json()
if result['response']['status'] == 'success':
print(f"Device logged out: {result['response']['logout']['deviceName']}")
return True
else:
print(f"Error: {result['response']['msg']}")
return False
# Usage
logout_device('abc123def456ghi789jkl012mno345pqr678stu901vwx234yz')Example 3: Secure Account by Logging Out All Other Devices
<?php
function secureAccount() {
$url = "https://unify.smsgateway.center/SMSApi/security/logoutAllOtherDevices";
$postData = array(
'userid' => 'YourUsername',
'password' => 'YourPassword',
'output' => 'json'
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
if ($data['response']['status'] === 'success') {
$logoutAll = $data['response']['logoutAll'];
echo "Account secured successfully!\n";
echo "Devices logged out: " . $logoutAll['devicesLoggedOut'] . "\n";
echo "Current session ID: " . $logoutAll['currentSessionId'] . "\n";
return true;
} else {
echo "Error: " . $data['response']['msg'] . "\n";
return false;
}
}
// Usage
secureAccount();
Example 4: Monitor and Auto-Logout Inactive Devices
// JavaScript example - Logout devices inactive for more than 30 days
async function cleanupInactiveDevices() {
const formData = new FormData();
formData.append('userid', 'YourUsername');
formData.append('password', 'YourPassword');
formData.append('output', 'json');
const response = await fetch('https://unify.smsgateway.center/SMSApi/security/connectedDevices', {
method: 'POST',
body: formData
});
const data = await response.json();
if (data.response.status === 'success') {
const sessions = data.response.sessions;
const thirtyDaysAgo = Date.now() - (30 * 24 * 60 * 60 * 1000);
for (const session of sessions) {
// Skip current session
if (session.isCurrentSession) continue;
// Check if inactive for more than 30 days
if (session.lastActivityTimestamp < thirtyDaysAgo) {
const logoutFormData = new FormData();
logoutFormData.append('userid', 'YourUsername');
logoutFormData.append('password', 'YourPassword');
logoutFormData.append('sessionId', session.sessionId);
logoutFormData.append('output', 'json');
await fetch('https://unify.smsgateway.center/SMSApi/security/logoutDevice', {
method: 'POST',
body: logoutFormData
});
console.log(`Logged out inactive device: ${session.deviceName}`);
}
}
}
}
cleanupInactiveDevices();Best Practices
Recommendations
- Regular Monitoring: Periodically check connected devices to detect unauthorized access
- Session Management: Logout devices you no longer use or recognize
- Security Alerts: Monitor for suspicious locations or IP addresses
- Current Session: Always check
isCurrentSessionbefore logging out to avoid logging yourself out - Error Handling: Implement comprehensive error handling for all error codes (448-456)
- Session IDs: Store session IDs securely if you need to reference them later
- Auto-Cleanup: Consider implementing automatic logout for inactive sessions
- Location Verification: Verify device locations match expected geographic areas
- IP Monitoring: Track IP addresses for security auditing purposes
- Account Security: Use "Logout All Other Devices" if you suspect account compromise
Use Cases
Account Security
Monitor and manage active sessions to secure your account from unauthorized access.
Device Management
View all connected devices and logout specific devices you no longer use.
Location Tracking
Monitor device locations and IP addresses to detect suspicious activity.
Activity Monitoring
Track last activity time for each session and cleanup inactive devices.
Testimonials
Why do Great Businesses Trust SMS Gateway Center?

