Skip to main content

What are Instances?

In Evolution API, an instance represents a single WhatsApp connection. Each instance operates independently with its own:
  • WhatsApp session and authentication state
  • Connection status and QR code
  • Configuration settings (webhooks, events, proxies)
  • Database isolation (messages, contacts, chats)
  • Event handlers and integrations
Think of an instance as a virtual WhatsApp client. You can create multiple instances to manage different WhatsApp numbers or business accounts from a single Evolution API server.
Each instance has a unique instanceName that identifies it across all API operations. This name must be unique within your Evolution API installation.

Instance Architecture

Evolution API uses the WAMonitoringService to manage instance lifecycle and state. When you create an instance, the system:
  1. Generates a unique instanceId (UUID)
  2. Creates a database record with connection metadata
  3. Initializes the WhatsApp channel (Baileys, Business API, or Evolution)
  4. Stores authentication state (Redis, database, or provider storage)
  5. Sets up event listeners and webhook configurations
Here’s how instances are stored and tracked:

Creating an Instance

To create a new instance, send a POST request to /instance/create:
Store the returned hash (instance token) securely. You’ll need it to authenticate subsequent requests to this specific instance.

Create with Webhook Configuration

You can configure webhooks during instance creation:

Create with Settings

Configure instance behavior at creation time:

Connecting to WhatsApp

After creating an instance, you need to connect it to WhatsApp:

Using QR Code (Baileys)

1

Request QR Code

If you set qrcode: true during creation, the QR code is returned immediately. Otherwise, connect manually:
2

Scan QR Code

The response contains a base64-encoded QR code:
Display this QR code in your application or scan it directly with WhatsApp.
3

Wait for Connection

Monitor the connection status:
When connected, status changes to open.

Using Phone Number (Business API)

For WhatsApp Business API integration:
Business API instances connect automatically without QR codes, using Meta’s authentication system.

Instance Lifecycle Management

Evolution API provides complete instance lifecycle control:

Check Connection State

Response:
Possible states:
  • close - Not connected
  • connecting - QR code displayed, waiting for scan
  • open - Connected and ready

Restart Instance

Restart a connected instance without logging out:
Restarting refreshes the connection without destroying the session. Useful for applying configuration changes or recovering from connection issues.

Logout Instance

Disconnect from WhatsApp while preserving the instance:
This removes the WhatsApp session but keeps the instance configuration. You’ll need to scan a new QR code to reconnect.

Delete Instance

Permanently remove an instance and all its data:
Deleting an instance removes all associated data including messages, contacts, and chats. This action cannot be undone.
From the source code (src/api/services/monitor.service.ts:452):

Instance Isolation

Evolution API ensures complete isolation between instances:

Database Isolation

Every database query includes the instanceId to prevent data leakage:

Memory Isolation

Each instance runs in its own context:

Authentication Isolation

Instances can use different authentication methods:
  • Global API Key: Access all instances
  • Instance Token: Access only specific instance

Auto-Cleanup and Expiration

Evolution API can automatically remove disconnected instances:
From src/api/services/monitor.service.ts:45:
Set DEL_INSTANCE=false to disable automatic cleanup and keep all instances in memory permanently.

Fetching Instance Information

Retrieve detailed information about your instances:

Fetch All Instances

Fetch Specific Instance

Response includes:

Best Practices

Choose clear, meaningful names that identify the purpose:
  • sales-brazil, support-team-1, customer-bot
  • instance1, test, my-instance
Instance names cannot be changed after creation.
Each instance receives a unique authentication token. Store these securely:
Never commit tokens to version control.
Implement health checks to monitor instance connectivity:
Subscribe to instance lifecycle events via webhooks:
  • INSTANCE_CREATE - New instance created
  • INSTANCE_DELETE - Instance deleted
  • CONNECTION_UPDATE - Connection state changed
  • QRCODE_UPDATED - New QR code available
  • REMOVE_INSTANCE - Instance auto-removed
Design your architecture to support multiple instances:
  • Use unique names per tenant/customer
  • Store instance metadata in your database
  • Implement connection pooling for database access
  • Consider using Redis for session storage at scale

Next Steps

Authentication

Learn how to secure your instances with API keys

Webhooks

Configure webhooks to receive real-time events

Multi-Tenant

Build multi-tenant applications with instance isolation

Send Messages

Start sending messages with your instance