Skip to content

WhatsApp Instances

A WhatsApp “instance” in Evolution API Lite represents a single WhatsApp connection that can send and receive messages. Each instance maintains its own authentication session, connection state, and configuration settings.

An instance is essentially a virtual WhatsApp client that:

  • Maintains a persistent connection to WhatsApp servers
  • Has its own phone number and authentication session
  • Can send and receive messages independently
  • Maintains separate contacts, chats, and message history
  • Has configurable settings and behavior

Think of each instance as a separate WhatsApp account that you can control programmatically through the API.

Instances are created using the /instance/create endpoint with the global API key:

Terminal window
curl -X POST http://localhost:8080/instance/create \
-H "Content-Type: application/json" \
-H "apikey: YOUR_GLOBAL_API_KEY" \
-d '{
"instanceName": "my-whatsapp-bot",
"integration": "WHATSAPP-BAILEYS",
"qrcode": true
}'

Response:

{
"instance": {
"instanceName": "my-whatsapp-bot",
"instanceId": "550e8400-e29b-41d4-a716-446655440000",
"integration": "WHATSAPP-BAILEYS",
"status": "connecting"
},
"hash": "B8E7F2A1-9C3D-4E5F-8A2B-1D3E4F5A6B7C",
"qrcode": {
"code": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
"base64": "iVBORw0KGgoAAAANSUhEUgAA..."
}
}

Instances can be in one of several connection states:

StateDescriptionActions Available
connectingAttempting to connect to WhatsAppWait for QR code scan or connection
openSuccessfully connected and readyAll messaging operations
closeDisconnected from WhatsAppReconnect or delete

For Baileys integration (WhatsApp Web):

  1. QR Code Generation: Instance generates a QR code for authentication
  2. QR Code Scan: User scans the QR code with their WhatsApp mobile app
  3. Session Establishment: Instance receives authentication credentials
  4. Connection Open: Instance is ready to send/receive messages

Initiate or check the connection status:

Terminal window
curl -X POST http://localhost:8080/instance/connect/my-whatsapp-bot \
-H "apikey: INSTANCE_TOKEN"

Get the current connection status:

Terminal window
curl -X GET http://localhost:8080/instance/connectionState/my-whatsapp-bot \
-H "apikey: INSTANCE_TOKEN"

Response:

{
"instance": {
"instanceName": "my-whatsapp-bot",
"state": "open"
}
}

Restart a connected instance (useful for troubleshooting):

Terminal window
curl -X POST http://localhost:8080/instance/restart/my-whatsapp-bot \
-H "apikey: INSTANCE_TOKEN"

Logout from WhatsApp (maintains instance but disconnects):

Terminal window
curl -X POST http://localhost:8080/instance/logout/my-whatsapp-bot \
-H "apikey: INSTANCE_TOKEN"

Permanently delete an instance and all its data:

Terminal window
curl -X DELETE http://localhost:8080/instance/delete/my-whatsapp-bot \
-H "apikey: INSTANCE_TOKEN"

Get information about all instances (requires global API key):

Terminal window
curl -X GET http://localhost:8080/instance/fetchInstances \
-H "apikey: YOUR_GLOBAL_API_KEY"

Get information about a specific instance:

Terminal window
curl -X GET http://localhost:8080/instance/fetchInstances?instanceName=my-whatsapp-bot \
-H "apikey: INSTANCE_TOKEN"

Response:

[
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "my-whatsapp-bot",
"connectionStatus": "open",
"ownerJid": "5511999999999@s.whatsapp.net",
"profileName": "My Bot",
"profilePicUrl": "https://...",
"number": "5511999999999",
"integration": "WHATSAPP-BAILEYS",
"token": "B8E7F2A1-9C3D-4E5F-8A2B-1D3E4F5A6B7C",
"_count": {
"Message": 150,
"Contact": 45,
"Chat": 12
}
}
]

Each instance can have custom settings that control its behavior:

{
"rejectCall": true,
"msgCall": "I'm a bot, please send a text message",
"groupsIgnore": false,
"alwaysOnline": true,
"readMessages": true,
"readStatus": true,
"syncFullHistory": false
}
SettingDescriptionDefault
rejectCallAutomatically reject incoming callsfalse
msgCallMessage to send when rejecting calls""
groupsIgnoreIgnore messages from groupsfalse
alwaysOnlineKeep instance always onlinefalse
readMessagesAutomatically mark messages as readfalse
readStatusAutomatically read status updatesfalse
syncFullHistorySync full message history on connectfalse

Configure webhooks to receive real-time events:

{
"webhook": {
"enabled": true,
"url": "https://your-server.com/webhook",
"byEvents": false,
"base64": true,
"headers": {
"Authorization": "Bearer your-token"
}
}
}

Configure proxy settings for instances that need to route through specific networks:

{
"proxyHost": "proxy.example.com",
"proxyPort": 8080,
"proxyProtocol": "http",
"proxyUsername": "username",
"proxyPassword": "password"
}

Regularly monitor instance connection states, especially in production environments:

Terminal window
# Check all instances status
curl -X GET http://localhost:8080/instance/fetchInstances \
-H "apikey: YOUR_GLOBAL_API_KEY" \
| jq '.[] | {name: .name, status: .connectionStatus}'

Implement proper error handling for instance operations:

  • Connection failures: Retry connection with exponential backoff
  • Authentication errors: Generate new QR code or check credentials
  • Rate limiting: Respect WhatsApp’s rate limits to avoid temporary blocks
  • Store instance tokens securely
  • Rotate tokens periodically
  • Monitor for unusual activity
  • Use HTTPS for all API calls

If the QR code expires before scanning:

  1. Restart the instance to generate a new QR code
  2. Ensure the mobile device has stable internet connection
  3. Try using a different browser or clearing cache

If instances frequently disconnect:

  1. Check server internet connection stability
  2. Verify WhatsApp account is not logged in elsewhere
  3. Consider using proxy configuration if behind firewall
  4. Monitor server resources (CPU, memory)

If authentication fails repeatedly:

  1. Logout and reconnect the instance
  2. Clear WhatsApp Web sessions in mobile app
  3. Verify the phone number is valid and active
  4. Check for account restrictions or bans