Get Active Devices API
POST /getActiveDevices
Description
This endpoint retrieves information about all active devices, including their status and connection details.
Request
Endpoint: /getActiveDevices
Method: POST
Body:
query getActiveDevices {
getActiveDevices {
id
userId
os
deviceId
loginDate
logoutDate
appVersion
deviceModel
deviceName
fcmToken
isActive
isBlocked
}
}
GraphQL Variables:
{}
Example Request
cURL:
curl --location 'YOUR_API_ENDPOINT' \
--header 'Content-Type: application/json' \
--data '{"query":"query getActiveDevices {\n getActiveDevices {\n id\n userId\n os\n deviceId\n loginDate\n logoutDate\n appVersion\n deviceModel\n deviceName\n fcmToken\n isActive\n isBlocked\n }\n}","variables":{}}'
Response
The response will include a list of active devices with the following fields:
id
: Unique identifier of the device record.userId
: Unique identifier of the user associated with the device.os
: Operating system of the device.deviceId
: Unique identifier of the device.loginDate
: Date and time when the device last logged in.logoutDate
: Date and time when the device last logged out.appVersion
: Version of the application running on the device.deviceModel
: Model of the device.deviceName
: Name assigned to the device.fcmToken
: Firebase Cloud Messaging token for the device.isActive
: Boolean indicating if the device is currently active.isBlocked
: Boolean indicating if the device is blocked.
Errors
- 500 Internal Server Error: Server error while processing the request.
- 403 Forbidden: User does not have permission to view active devices.
Notes
- Ensure proper access controls are in place, as this endpoint returns sensitive information about user devices.
- The
loginDate
andlogoutDate
fields will show the most recent login and logout timestamps, respectively. Devices that have not logged out may have alogoutDate
ofnull
. - The
isActive
field indicates whether the device is currently active, whileisBlocked
indicates if the device has been blocked by an administrator. - This endpoint may return a large dataset if many devices are active. Consider implementing pagination or filtering if performance becomes an issue.