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/jsonand theX-API-KEYheader. - 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
- Axios
- Fetch
- Guzzle
- curl (PHP)
- requests
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"
}'
import axios from 'axios';
await axios.post('https://api.communiktor.com/instances/start', {
instance: 'my-instance-1',
}, {
headers: { 'Content-Type': 'application/json', 'X-API-KEY': 'YOUR_API_KEY' }
});
await fetch('https://api.communiktor.com/instances/start', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': 'YOUR_API_KEY'
},
body: JSON.stringify({ instance: 'my-instance-1' })
});
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://api.communiktor.com']);
$response = $client->post('/instances/start', [
'headers' => [ 'Content-Type' => 'application/json', 'X-API-KEY' => 'YOUR_API_KEY' ],
'json' => [ 'instance' => 'my-instance-1' ]
]);
echo $response->getBody();
<?php
$ch = curl_init('https://api.communiktor.com/instances/start');
$payload = json_encode(['instance' => 'my-instance-1']);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'X-API-KEY: YOUR_API_KEY' ],
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
]);
$response = curl_exec($ch);
if ($response === false) { throw new Exception(curl_error($ch)); }
curl_close($ch);
echo $response;
import requests
r = requests.post('https://api.communiktor.com/instances/start', json={
'instance': 'my-instance-1'
}, headers={
'Content-Type': 'application/json',
'X-API-KEY': 'YOUR_API_KEY'
})
print(r.json())
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
- Axios
- Fetch
- Guzzle
- curl (PHP)
- requests
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"
}'
import axios from 'axios';
await axios.post('https://api.communiktor.com/instances/restart', {
instance: 'my-instance-1'
}, { headers: { 'Content-Type': 'application/json', 'X-API-KEY': 'YOUR_API_KEY' } });
await fetch('https://api.communiktor.com/instances/restart', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'X-API-KEY': 'YOUR_API_KEY' },
body: JSON.stringify({ instance: 'my-instance-1' })
});
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://api.communiktor.com']);
$client->post('/instances/restart', [
'headers' => [ 'Content-Type' => 'application/json', 'X-API-KEY' => 'YOUR_API_KEY' ], 'json' => [ 'instance' => 'my-instance-1' ]
]);
<?php
$ch = curl_init('https://api.communiktor.com/instances/restart');
$payload = json_encode(['instance' => 'my-instance-1']);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'X-API-KEY: YOUR_API_KEY' ],
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
]);
$resp = curl_exec($ch);
if ($resp === false) { throw new Exception(curl_error($ch)); }
curl_close($ch);
echo $resp;
import requests
print(requests.post('https://api.communiktor.com/instances/restart', json={'instance': 'my-instance-1'}, headers={'Content-Type':'application/json','X-API-KEY':'YOUR_API_KEY'}).json())
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
- Axios
- Fetch
- Guzzle
- curl (PHP)
- requests
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"
}'
import axios from 'axios';
await axios.post('https://api.communiktor.com/instances/stop', { instance: 'my-instance-1' }, { headers: { 'Content-Type': 'application/json', 'X-API-KEY': 'YOUR_API_KEY' } });
await fetch('https://api.communiktor.com/instances/stop', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'X-API-KEY': 'YOUR_API_KEY' },
body: JSON.stringify({ instance: 'my-instance-1' })
});
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://api.communiktor.com']);
$client->post('/instances/stop', [
'headers' => [ 'Content-Type' => 'application/json', 'X-API-KEY' => 'YOUR_API_KEY' ],
'json' => [ 'instance' => 'my-instance-1' ]
]);
<?php
$ch = curl_init('https://api.communiktor.com/instances/stop');
$payload = json_encode(['instance' => 'my-instance-1']);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'X-API-KEY: YOUR_API_KEY' ],
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
]);
$resp = curl_exec($ch);
if ($resp === false) { throw new Exception(curl_error($ch)); }
curl_close($ch);
echo $resp;
import requests
print(requests.post('https://api.communiktor.com/instances/stop', json={'instance': 'my-instance-1'}, headers={'Content-Type':'application/json','X-API-KEY':'YOUR_API_KEY'}).json())
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
- Axios
- Fetch
- Guzzle
- curl (PHP)
- requests
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"
}'
import axios from 'axios';
await axios.post('https://api.communiktor.com/instances/disconnect', { instance: 'my-instance-1' }, { headers: { 'Content-Type': 'application/json', 'X-API-KEY': 'YOUR_API_KEY' } });
await fetch('https://api.communiktor.com/instances/disconnect', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'X-API-KEY': 'YOUR_API_KEY' },
body: JSON.stringify({ instance: 'my-instance-1' })
});
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://api.communiktor.com']);
$client->post('/instances/disconnect', [
'headers' => [ 'Content-Type' => 'application/json', 'X-API-KEY' => 'YOUR_API_KEY' ],
'json' => [ 'instance' => 'my-instance-1' ]
]);
<?php
$ch = curl_init('https://api.communiktor.com/instances/disconnect');
$payload = json_encode(['instance' => 'my-instance-1']);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'X-API-KEY: YOUR_API_KEY' ],
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
]);
$resp = curl_exec($ch);
if ($resp === false) { throw new Exception(curl_error($ch)); }
curl_close($ch);
echo $resp;
import requests
print(requests.post('https://api.communiktor.com/instances/disconnect', json={'instance': 'my-instance-1'}, headers={'Content-Type':'application/json','X-API-KEY':'YOUR_API_KEY'}).json())
Link an instance with a QR code
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
- Axios
- Fetch
- Guzzle
- curl (PHP)
- requests
curl -X GET "https://api.communiktor.com/instances/qr?instance=my-instance-1" \
-H "X-API-KEY: YOUR_API_KEY"
import axios from 'axios';
const { data } = await axios.get('https://api.communiktor.com/instances/qr', {
params: {
instance: 'my-instance-1'
},
headers: { 'X-API-KEY': 'YOUR_API_KEY' },
});
console.log(data);
const url = new URL('https://api.communiktor.com/instances/qr');
url.searchParams.set('instance', 'my-instance-1');
const res = await fetch(url, { headers: { 'X-API-KEY': 'YOUR_API_KEY' } });
console.log(await res.json());
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://api.communiktor.com']);
$response = $client->get('/instances/qr', [
'headers' => ['X-API-KEY' => 'YOUR_API_KEY'],
'query' => [
'instance' => 'my-instance-1',
],
]);
echo $response->getBody();
<?php
$query = http_build_query([
'instance' => 'my-instance-1',
]);
$ch = curl_init('https://api.communiktor.com/instances/qr?' . $query);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-KEY: YOUR_API_KEY'],
]);
$response = curl_exec($ch);
if ($response === false) { throw new Exception(curl_error($ch)); }
curl_close($ch);
echo $response;
import requests
response = requests.get(
'https://api.communiktor.com/instances/qr',
params={
"instance": "my-instance-1"
},
headers={'X-API-KEY': 'YOUR_API_KEY'},
)
print(response.json())
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"
}
}
Link an instance with a pairing code
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
- Axios
- Fetch
- Guzzle
- curl (PHP)
- requests
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"
}'
import axios from 'axios';
const { data } = await axios.post('https://api.communiktor.com/instances/code', {
instance: 'my-instance-1',
phone: '14155552671'
}, {
headers: { 'Content-Type': 'application/json', 'X-API-KEY': 'YOUR_API_KEY' },
});
console.log(data);
const res = await fetch('https://api.communiktor.com/instances/code', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'X-API-KEY': 'YOUR_API_KEY' },
body: JSON.stringify({
instance: 'my-instance-1',
phone: '14155552671'
}),
});
console.log(await res.json());
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
$client = new Client(['base_uri' => 'https://api.communiktor.com']);
$response = $client->post('/instances/code', [
'headers' => ['Content-Type' => 'application/json', 'X-API-KEY' => 'YOUR_API_KEY'],
'json' => [
'instance' => 'my-instance-1',
'phone' => '14155552671',
],
]);
echo $response->getBody();
<?php
$payload = json_encode([
'instance' => 'my-instance-1',
'phone' => '14155552671',
]);
$ch = curl_init('https://api.communiktor.com/instances/code');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Content-Type: application/json', 'X-API-KEY: YOUR_API_KEY'],
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
]);
$response = curl_exec($ch);
if ($response === false) { throw new Exception(curl_error($ch)); }
curl_close($ch);
echo $response;
import requests
response = requests.post(
'https://api.communiktor.com/instances/code',
json={
"instance": "my-instance-1",
"phone": "14155552671"
},
headers={'Content-Type': 'application/json', 'X-API-KEY': 'YOUR_API_KEY'},
)
print(response.json())
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.