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
- 401
- 403
- 404
- 409
- 502
- 503
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
The API key is missing, unknown, revoked, or expired
The API key's role, session or chat scope, or IP allow-list does not allow this operation
Session not found
Baileys: the session has no linked WhatsApp device (it never linked, its pairing code was never entered, or the phone removed the link), so there is nothing to unlink. It was stopped locally and phone is cleared; no success audit is written. Start it to link a device, or delete it, instead of retrying the logout.
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.
The database did not answer the read of the session, so nothing was logged out. Retry the logout.