Skip to main content

Managing Instances

An instance represents a single WhatsApp number connected to Wappfy. Each instance goes through a lifecycle: create, connect, scan QR, use, and eventually disconnect or delete.

Instance Types

Wappfy supports two providers:

Instance Status Values

Throughout its lifecycle, an instance transitions through these statuses:

Lifecycle Overview


Create an Instance

Create a new WhatsApp instance tied to your account.
Response:

Connect an Instance

Start the WhatsApp session. The instance will transition to starting and then to scan_qr.
Response:

Get the QR Code

Once the instance reaches scan_qr status, retrieve the QR code to scan with your phone.
Response:
The QR code expires after approximately 60 seconds. If it expires before you scan it, call the endpoint again to get a fresh code.
Open the QR code image and scan it with WhatsApp > Linked Devices > Link a Device on your phone. Once scanned, the instance status will change to connected.

Check Instance Status

Poll the status endpoint to know when the instance is ready.
Response:
Instead of polling, set up a webhook for instance.connected and instance.qr events to get notified in real-time.

List All Instances

Retrieve all instances for your account.
Response:

Disconnect an Instance

Stop the WhatsApp session without deleting the instance. You can reconnect later.

Restart an Instance

Restart the WhatsApp session. This is useful if the instance is in a failed state or behaving unexpectedly.
Restarting preserves the linked WhatsApp session. You will not need to scan the QR code again.

Logout an Instance

Log out from WhatsApp entirely. This unlinks the phone from the session. You will need to scan the QR code again to reconnect.
Logout completely removes the WhatsApp link. Unlike disconnect, you must scan a new QR code to use this instance again.

Delete an Instance

Permanently delete an instance and all its associated data.
This action is irreversible. All messages, webhooks, and configuration associated with this instance will be permanently deleted.

Full Lifecycle Example

Here is a complete example that creates an instance, connects it, and polls for the QR code:

Error Handling