Add Device

This API is responsible for adding a new device.

Important Note:

If the value of device_management is set to 1, which means that the system is enabled. This configuration is obtained from the server at the endpoint /api/base/configs. The system will remain enabled until you explicitly disable it.

On the other hand, if the value of device_management is anything other than 1, the system is considered disabled.

To provide a seamless user experience, it is essential to handle the error message display only when the device_banned status code is received. In all other cases, no error code should impact the user experience. Prioritizing a smooth user interaction, ensure that unnecessary interruptions or error messages for non-banned devices are avoided.

Furthermore, to maintain an uninterrupted user experience, it is recommended to verify that the device has an active internet connection before sending these requests. If the internet is not connected, refrain from sending these requests to prevent any adverse effects on the user experience.

API Route

{{apiBase}}/v2/device

Request

  • Method: POST

Parameters

The function expects the following parameters to be included in the request's body:

  • mac_address: The MAC address of the device.

  • device_os: The operating system of the device.

  • device_version: The version of the device.

  • device_type: The type of the device.

  • app_version: The version of the application.

  • app_name: The name of the application.

Success Response

  • Status: 200

  • Description: Indicates that the device was added successfully.

  • Body: The response body contains the details of the added device in JSON format.

{
    "status": 200,
    "timestamp": 1684581841,
    "time": 0.583,
    "ip": "127.0.0.1",
    "message": "Success",
    "data": {
        "mac_address": "A1B2C3D4E5F6",
        "status": 1,
        "ban_status": 0
    }
}

Error Response

  • Status: 400

  • Description: Indicates an error occurred during the device addition process.

  • Body: The response body provides information about the specific error that occurred.

Usage Example

{
    "mac_address": "A1B2C3D4E5F6",
    "device_os": "iOS",
    "device_version": "14.5",
    "device_type": "Mobile",
    "app_version": "2.0",
    "app_name": "MyApp"
}

Notes

  • If the mac_address provided already exists in the system, the device will be updated with the new information.

  • If any of the required parameters (device_os, device_version, device_type, mac_address, app_version, app_name) are missing or empty, the API will return a 400 status with an appropriate error message.

Please note that the provided code snippet represents a simplified version of the add_device function. Additional logic and error handling may exist in the actual implementation.

Last updated