> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ryzeapi.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Logout Instance

> Forces a WhatsApp logout and disconnects the device, while keeping the instance record

**Auth:** `TokenAccount` or `TokenInstance` • **Rate-limit:** `Global` (100/min) • **Idempotent:** yes

## Description

Unlinks the device from WhatsApp (the equivalent of clicking "Log out" in WhatsApp Web) and closes the websocket. The instance record is **not** deleted, the token remains valid for a future [`connect`](/en/api/instance/connect) (with a new QR).

## Example

Sends a `DELETE` to the logout path to unlink the device from WhatsApp and close the WebSocket. The instance record is preserved, so the same `token` can be reused on a future call to `connect`.

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE "https://ryzeapi.cloud/api/instance/logout/my-instance" \
    -H "token: $Token_Instance"
  ```

  ```javascript JavaScript theme={null}
  await fetch("https://ryzeapi.cloud/api/instance/logout/my-instance", {
    method: "DELETE",
    headers: {
      "token": process.env.Token_Instance
    }
  });
  ```

  ```python Python theme={null}
  import os, requests

  requests.delete(
      "https://ryzeapi.cloud/api/instance/logout/my-instance",
      headers={
          "token": os.environ["Token_Instance"]
      }
  )
  ```

  ```go Go theme={null}
  package main

  import (
      "net/http"
      "os"
  )

  func main() {
      req, _ := http.NewRequest("DELETE", "https://ryzeapi.cloud/api/instance/logout/my-instance", nil)
      req.Header.Set("token", os.Getenv("Token_Instance"))
      http.DefaultClient.Do(req)
  }
  ```
</CodeGroup>

## Success response

```json 200 OK theme={null}
{
  "success": true,
  "message": "Instance logged out",
  "instance": {
    "status": "loggedout"
  }
}
```

## Path parameters

<ParamField path="instance" type="string" required>
  Instance name.
</ParamField>

## Headers

<ParamField header="token" type="string" required>
  TokenAccount or TokenInstance.
</ParamField>

## Errors

| HTTP | `error.message`                         | When                      |
| :--: | --------------------------------------- | ------------------------- |
|  401 | `Invalid token`                         | Token missing or invalid. |
|  404 | `Instance not found`                    | Name does not exist.      |
|  429 | `Rate limit exceeded. Try again later.` | More than 100 req/min.    |
|  500 | `Failed to logout instance`             | Internal failure.         |

```json theme={null}
{
  "success": false,
  "error": {
    "message": "Instance not found"
  }
}
```

## Notes

<Note>
  After logout, **`reconnect` no longer works**, the whatsmeow session is wiped. Use [`connect`](/en/api/instance/connect) to generate a new QR.
</Note>

<Warning>
  This **does not** delete the instance record. To remove it completely (including settings, webhooks, and data), use [`DELETE /api/instance/delete/:instance`](/en/api/instance/delete).
</Warning>

## Next

<CardGroup cols={2}>
  <Card title="Connect again" icon="qrcode" href="/en/api/instance/connect">
    Generate a new QR to link another device.
  </Card>

  <Card title="Delete instance" icon="trash" href="/en/api/instance/delete">
    To remove everything permanently.
  </Card>
</CardGroup>
