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

# Pairing and connection

> Connect a token, get QR data, request a pairing code, disconnect, or logout.

## Connect token

Starts the WhatsApp runtime in the background. Use this for first-time pairing and for reconnecting a paired token after the runtime becomes inactive.

```http theme={null}
POST /api/v1/sessions/{sessionId}/connect
Authorization: Bearer <api_key>
```

## Reconnect a paired token

Reconnect is the same API call as connect:

```http theme={null}
POST /api/v1/sessions/{sessionId}/connect
Authorization: Bearer <api_key>
```

Use reconnect when a token is already paired but not ready to send:

```json theme={null}
{
  "paired": true,
  "active": false,
  "connected": false,
  "connectionState": "inactive"
}
```

WADial reuses the existing WhatsApp credentials. You do not need to scan QR or request a pairing code again unless the token was logged out or unpaired.

## Get QR

```http theme={null}
GET /api/v1/sessions/{sessionId}/auth/qr
Authorization: Bearer <api_key>
```

## Connect by pairing code

Pairing code is only for tokens that are not paired yet. Start the runtime with `connect`, then request a code.

```http theme={null}
POST /api/v1/sessions/{sessionId}/auth/pairing-code
Authorization: Bearer <api_key>
Content-Type: application/json
```

```json theme={null}
{
  "phoneNumber": "15551234567"
}
```

If the token is already paired, use reconnect instead of requesting another pairing code.

## Disconnect

Disconnects the runtime while keeping reusable credentials.

```http theme={null}
POST /api/v1/sessions/{sessionId}/disconnect
Authorization: Bearer <api_key>
```

## Logout

Logs out the linked device. Use this when the token should be unpaired.

```http theme={null}
POST /api/v1/sessions/{sessionId}/logout
Authorization: Bearer <api_key>
```

## Status events

```http theme={null}
GET /api/v1/sessions/{sessionId}/events
Authorization: Bearer <api_key>
Accept: text/event-stream
```
