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

# POST /v1/numbers/{id}/logout — Logout WhatsApp Instance

> POST /v1/numbers/{id}/logout — Disconnect a WhatsApp instance without removing it from the database.

# Logout WhatsApp instance

`POST /v1/numbers/{id}/logout` disconnects a WhatsApp instance (logout) without removing it from the database. This is different from `DELETE /v1/numbers/{id}` which permanently removes the instance.

```bash theme={null}
curl -X POST "https://pilotstatus.com.br/v1/numbers/wa_abc/logout" \
  -H "x-api-key: ps_your_token_here"
```

Response:

```json theme={null}
{
  "ok": true,
  "instances": [
    {
      "instanceId": "inst_123",
      "ok": true
    }
  ]
}
```

## When to use it

* When you want to disconnect a WhatsApp instance temporarily without deleting it.
* When you need to reconnect a number to a different device.
* When troubleshooting connection issues and need to reset the connection state.

## Differences from DELETE

| Operation                      | What it does                                                                                           |
| ------------------------------ | ------------------------------------------------------------------------------------------------------ |
| `POST /v1/numbers/{id}/logout` | Disconnects WhatsApp (unlinks device) but keeps the instance in the database. You can reconnect later. |
| `DELETE /v1/numbers/{id}`      | Disconnects AND permanently removes the instance from the database. Cannot be undone.                  |

## Request parameters

| Parameter | Type   | Required | Description                                     |
| --------- | ------ | -------- | ----------------------------------------------- |
| `id`      | string | Yes      | The WhatsApp instance ID or WhatsApp number ID. |

## Response

### Success (200)

```json theme={null}
{
  "ok": true,
  "instances": [
    {
      "instanceId": "inst_123",
      "ok": true
    }
  ]
}
```

| Field                    | Type    | Description                                                       |
| ------------------------ | ------- | ----------------------------------------------------------------- |
| `ok`                     | boolean | Overall success status.                                           |
| `instances`              | array   | Array of logout results for each instance.                        |
| `instances[].instanceId` | string  | The instance ID.                                                  |
| `instances[].ok`         | boolean | Whether logout succeeded for this instance.                       |
| `instances[].error`      | string  | Error message if logout failed (only present when `ok` is false). |

### Errors

| Status | Body                                   | Meaning                          |
| ------ | -------------------------------------- | -------------------------------- |
| `401`  | `{ "error": "…" }`                     | Invalid or missing API key.      |
| `404`  | `{ "error": "Number not found" }`      | No such number for this API key. |
| `500`  | `{ "error": "Internal server error" }` | Server error (check logs).       |

## Notes

* The logout is **best-effort**: if the upstream provider returns a benign error (e.g., instance not found, 401), it is silently ignored and the instance state is still updated.
* After logout, the instance state will be `LOGOUT` in the database.
* You can reconnect the instance later using `GET /v1/numbers/{id}/connect`.
