# Session Management

> Manage WhatsApp sessions with clear operational controls.

Source: https://wav1.recrav.com/docs/session-management

## Session Lifecycle [#session-lifecycle]

### Creating a Session [#creating-a-session]

1. Go to [Dashboard](/dashboard)
2. Click "New Session"
3. Name your session (e.g., "Production", "Support Team")
4. Scan the QR code with WhatsApp
5. Wait for "Connected" status

### Connection States [#connection-states]

| Status         | Description                    | Actions                  |
| -------------- | ------------------------------ | ------------------------ |
| `connecting`   | Initial connection in progress | Wait or check QR code    |
| `connected`    | Session is active and ready    | Send/receive messages    |
| `disconnected` | Session lost connection        | Check phone connectivity |
| `expired`      | QR code expired                | Generate new QR code     |

### Reconnecting [#reconnecting]

If your session disconnects:

1. Go to your session page
2. Click "Reconnect"
3. Scan the new QR code
4. Verify connection status

### Stopping a Session [#stopping-a-session]

To temporarily pause a session:

1. Go to session settings
2. Click "Stop Session"
3. The session will enter "disconnected" state
4. Reconnect anytime to resume

### Deleting a Session [#deleting-a-session]

To permanently remove a session:

1. Go to session settings
2. Click "Delete Session"
3. Confirm deletion
4. All associated API keys will be revoked

## Session Health [#session-health]

Monitor your session health in the dashboard:

* **Connection Status**: Green = healthy, Red = disconnected
* **Last Activity**: Time of last message sent/received
* **Message Queue**: Pending messages waiting to be sent

### Health Check API [#health-check-api]

```bash
curl -X GET "https://api.sendable.dev/sessions/{sessionId}/status" \
  -H "x-api-key: YOUR_API_KEY"
```

Response:

```json
{
  "sessionId": "sess_xyz789",
  "status": "connected",
  "connectedAt": "2026-03-02T10:30:00Z",
  "health": "healthy",
  "metrics": {
    "messagesSent": 1250,
    "messagesReceived": 890,
    "uptime": 99.9
  }
}
```

## Multi-Session Strategy [#multi-session-strategy]

### Separate by Use Case [#separate-by-use-case]

Create separate sessions for different purposes:

* **Marketing**: Bulk messaging campaigns
* **Support**: Customer service conversations
* **Notifications**: OTPs and alerts

### Separate by Region [#separate-by-region]

For international businesses:

* **US/EU**: Session with US phone number
* **Asia**: Session with Asian phone number
* **LatAm**: Session with Latin American number

## Operational Notes [#operational-notes]

### Keep Connection Healthy [#keep-connection-healthy]

* Keep WhatsApp mobile app active
* Ensure phone has stable internet
* Don't log out of WhatsApp on your phone
* Avoid switching phones frequently

### Handle Disconnections [#handle-disconnections]

Set up webhook to monitor disconnections:

```typescript
app.post('/webhook', (req, res) => {
  const { type, data } = req.body
  
  if (type === 'session.socket-disconnected') {
    // Alert your team
    sendAlert(`Session ${data.sessionId} disconnected`)
  }
  
  res.sendStatus(200)
})
```

### API Key Scoping [#api-key-scoping]

Each session has its own API keys:

* Keys from Session A cannot access Session B
* Revoking a session revokes all its keys
* Different sessions can have different rate limits
