Log out of WhatsApp (unlinks this device) and stop the session
POST/api/sessions/:sessionId/logout
Attempts an engine-native unlink of this companion device, then tears the session down locally. 200 means the engine-native unlink operation completed AND the required local credential cleanup completed — for Baileys a valid companion identity, an acknowledged remove-companion-device IQ response, and removal of the on-disk auth dir; for whatsapp-web.js the native Client.logout() promise settled. 200 is NOT an independent observation that the handset UI no longer shows the linked device. Because a completed unlink wipes the stored credentials, reconnecting after a 200 always requires a fresh QR scan or pairing code.
Request
Responses
- 200
- 400
- 404
- 502
Unlink operation and required local cleanup completed; session is stopped and phone is cleared. Recorded in the audit log as session_logged_out.
Session is not started (no engine to send through); the row is left untouched
Session not found
Session was stopped locally, but the logout operation is incomplete (no send, no acknowledgement, timeout/transport error, or local-cleanup failure). Retryable — the body carries code: 'SESSION_LOGOUT_INCOMPLETE'; phone is cleared and no success audit is written. Start the session again and retry the logout.