Skip to main content

Instances API

Manage your WhatsApp instances: link them to a WhatsApp account, start, restart, stop, and disconnect them. Each use case below is explained with concrete examples.

  • All requests are HTTP POST (unless stated otherwise) with Content-Type: application/json and the X-API-KEY header.
  • Responses follow { message: string, success: boolean, code: number, data: any }.

Start an instance​

Endpoint: POST /instances/start

When to use it

  • To initialize a newly created instance or relaunch after a stop.
  • Required before generating a QR if the instance was inactive.

Body

  • instance: string — Your instance identifier.
curl -X POST https://api.communiktor.com/instances/start \
-H "Content-Type: application/json" \
-H "X-API-KEY: YOUR_API_KEY" \
-d '{
"instance": "my-instance-1"
}'

Response

{
"success": true,
"code": 200,
"message": "Instance created",
"data": { "instanceId": "my-instance-1" }
}

Restart an instance​

Endpoint: POST /instances/restart

When to use it

  • After a configuration change.
  • To restore an unstable connection without forcing a new QR.

Body

  • instance: string — The instance identifier.
curl -X POST https://api.communiktor.com/instances/restart \
-H "Content-Type: application/json" \
-H "X-API-KEY: YOUR_API_KEY" \
-d '{
"instance": "my-instance-1"
}'

Stop an instance​

Endpoint: POST /instances/stop

When to use it

  • Take the instance offline gracefully.
  • Temporarily suspend sending/receiving messages.
  • The WhatsApp session is kept: start the instance again later without linking it again.

Body

  • instance: string — The instance identifier.
curl -X POST https://api.communiktor.com/instances/stop \
-H "Content-Type: application/json" \
-H "X-API-KEY: YOUR_API_KEY" \
-d '{
"instance": "my-instance-1"
}'

Disconnect the instance (logout)​

Endpoint: POST /instances/disconnect

When to use it

  • Log the instance out of WhatsApp: the device disappears from the phone's linked devices.
  • Useful if the phone changed or the session is corrupted.
  • The instance must then be linked again (QR code or pairing code).

POST /instances/shutdown is an alias of this endpoint, kept for compatibility.

Body

  • instance: string — The instance identifier.
curl -X POST https://api.communiktor.com/instances/disconnect \
-H "Content-Type: application/json" \
-H "X-API-KEY: YOUR_API_KEY" \
-d '{
"instance": "my-instance-1"
}'

Endpoint: GET /instances/qr

When to use it

  • To display the QR code in your own interface, for your customers to link their WhatsApp account.

Query parameters

  • instance: string — The instance identifier.

The instance must be started and not linked yet. data.qrCode is the raw content of the QR code: render it as a QR code image with any QR library. WhatsApp renews it about every 20 seconds, so fetch it again every few seconds (or use the instance.qr.generated webhook). data is null when no QR code is available: the instance is already connected, or not started yet.

On the phone: WhatsApp › Linked devices › Link a device, then scan the code.

curl -X GET "https://api.communiktor.com/instances/qr?instance=my-instance-1" \
-H "X-API-KEY: YOUR_API_KEY"

Response

{
"success": true,
"code": 200,
"message": "QR code retrieved successfully",
"data": {
"qrCode": "https://wa.me/settings/linked_devices#2@g/0cMMPnNea9KjssdfKnR8s7H3rwJAJa...",
"instanceId": "my-instance-1"
}
}

Endpoint: POST /instances/code

When to use it

  • To link a WhatsApp account without scanning a QR code, for example when the phone is the only screen available.

Body

  • instance: string — The instance identifier.
  • phone: string — Phone number of the WhatsApp account to link, international format, digits only.

The instance is started if needed. On the phone: WhatsApp › Linked devices › Link a device › Link with phone number instead, then enter the code. The same code is returned again for the same number for about 2 minutes; if WhatsApp refuses it, request a new one. If the response says the code is not available yet, retry after a few seconds.

curl -X POST https://api.communiktor.com/instances/code \
-H "Content-Type: application/json" \
-H "X-API-KEY: YOUR_API_KEY" \
-d '{
"instance": "my-instance-1",
"phone": "14155552671"
}'

Response

{
"success": true,
"code": 200,
"message": "Auth code retrieved",
"data": {
"code": "KJ7FHM6E",
"instanceId": "my-instance-1"
}
}

Once the account is linked, the instance.connected webhook is sent.