Skip to main content
POST
/
devices
/
{device_id}
/
logout
Logout Device
curl --request POST \
  --url https://api.example.com/devices/{device_id}/logout
{
  "404": {},
  "500": {},
  "code": "<string>",
  "message": "<string>",
  "results": "<string>"
}
Logout a device from WhatsApp and remove its session data. This will disconnect the device from WhatsApp servers and clear all authentication credentials.

Endpoint

POST /devices/{device_id}/logout

Authentication

This endpoint requires HTTP Basic Authentication.

Path Parameters

device_id
string
required
Device ID to logout from WhatsApp

Response

code
string
Response code
message
string
Response message
results
string
Additional result data (typically null)

Response Example

{
  "code": "SUCCESS",
  "message": "Device logged out successfully",
  "results": null
}

Error Responses

404
object
Device Not Found
500
object
Internal Server Error

Example Request

curl -X POST http://localhost:3000/devices/my-device-id/logout \
  -u username:password

What Happens During Logout

When you logout a device, the following actions occur:
  1. Session Termination: The device is disconnected from WhatsApp servers
  2. Credential Removal: All authentication credentials and session data are deleted
  3. State Update: Device state changes to disconnected
  4. Data Cleanup: Local session database is removed
This is a destructive operation. After logout:
  • The device will no longer receive messages
  • You cannot send messages from this device
  • You must login again (scan QR code or use pairing code) to use the device
  • The device will disappear from “Linked Devices” in WhatsApp mobile app

Use Cases

  • Deactivate a device before removing it from the system
  • Security: logout compromised devices
  • Re-authenticate a device with fresh credentials
  • Clean up devices that are no longer in use
  • Switch WhatsApp accounts on the same device

Device State After Logout

After successful logout, the device information will show:
{
  "id": "my-device-id",
  "phone_number": "",
  "display_name": "",
  "state": "disconnected",
  "jid": "",
  "created_at": "2024-01-01T00:00:00Z"
}

Re-login After Logout

To use the device again after logout:
  1. Call GET /devices//login to generate a new QR code
  2. Scan the QR code with WhatsApp mobile app
  3. Device will be logged in with fresh credentials
Alternatively, use the pairing code method for authentication.

Best Practices

Always logout a device before removing it from the system using the DELETE /devices/ endpoint. This ensures proper cleanup on both the API server and WhatsApp servers.
If you only want to temporarily disconnect a device without logging out, consider using the reconnect functionality instead. Logout is permanent and requires re-authentication.

Build docs developers (and LLMs) love