Appearance
Managing Devices 
This guide explains how to manage WhatsApp devices using the WhatsGate API.
Prerequisites 
Before you can manage devices, you need to:
- Create an API token for authentication
- Link a WhatsApp device to your account
Device Operations 
The WhatsGate API allows you to perform the following device operations:
- Connect a device
- Check device status
- Delete a device
Connecting a Device 
To connect a device and get a QR code for scanning, make a GET request to the /connect/{device} endpoint:
bash
curl -X GET \
  https://{subdomain}.whatsgate.net/api/connect/123456789 \
  -H 'Access-Token: your_api_token_here'Parameters 
- device: The mobile number of the device you want to connect
Response 
If successful, you'll receive a response with a QR code:
json
{
  "success": true,
  "qrCode": "data:image/png;base64,..."
}You can display this QR code to the user for scanning with their WhatsApp mobile app.
Error Handling 
If the device is not found or already connected, you'll receive an error response:
json
{
  "success": false,
  "message": "device not found!"
}or
json
{
  "success": false,
  "message": "device is already connected"
}Checking Device Status 
To check the connection status of a device, make a GET request to the /status/{device} endpoint:
bash
curl -X GET \
  https://{subdomain}.whatsgate.net/api/status/123456789 \
  -H 'Access-Token: your_api_token_here'Parameters 
- device: The mobile number of the device you want to check
Response 
The response will indicate the device's connection status:
json
{
  "success": true,
  "message": "connected"
}The status can be one of the following:
- "connected"
- "disconnected"
- "not connected"
- "not initialized"
Deleting a Device 
To delete a device connection, make a POST request to the /delete endpoint:
bash
curl -X POST \
  https://{subdomain}.whatsgate.net/api/delete \
  -H 'Access-Token: your_api_token_here' \
  -H 'Content-Type: application/json' \
  -d '{
    "sender_device": "123456789"
}'Parameters 
- sender_device: The mobile number of the device you want to delete
Response 
If successful, you'll receive a response confirming the deletion:
json
{
  "success": true,
  "message": "Device deleted successfully"
}Error Handling 
If the device is not found, you'll receive an error response:
json
{
  "success": false,
  "message": "The selected sender device is invalid."
}Best Practices 
Device Management 
- Regularly check the status of your devices to ensure they remain connected
- If a device disconnects, reconnect it as soon as possible to avoid message delivery failures
- Keep your WhatsApp mobile app updated on the device to ensure compatibility
Security 
- Only connect devices that you own and control
- Disconnect and delete devices that are no longer in use
- Regularly audit your connected devices to ensure security
