Deleting instances in bulk
curl --request POST \
--url https://api.z-api.io/instances/integrator/on-demand/batch-delete \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"instances": [
{
"id": "<string>",
"token": "<string>"
}
]
}
'import requests
url = "https://api.z-api.io/instances/integrator/on-demand/batch-delete"
payload = { "instances": [
{
"id": "<string>",
"token": "<string>"
}
] }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({instances: [{id: '<string>', token: '<string>'}]})
};
fetch('https://api.z-api.io/instances/integrator/on-demand/batch-delete', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.z-api.io/instances/integrator/on-demand/batch-delete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'instances' => [
[
'id' => '<string>',
'token' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.z-api.io/instances/integrator/on-demand/batch-delete"
payload := strings.NewReader("{\n \"instances\": [\n {\n \"id\": \"<string>\",\n \"token\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.z-api.io/instances/integrator/on-demand/batch-delete")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"instances\": [\n {\n \"id\": \"<string>\",\n \"token\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.z-api.io/instances/integrator/on-demand/batch-delete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"instances\": [\n {\n \"id\": \"<string>\",\n \"token\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyPartners
Deleting instances in bulk
Deletes several instances linked to your integrator partner account in a single request
POST
/
instances
/
integrator
/
on-demand
/
batch-delete
Deleting instances in bulk
curl --request POST \
--url https://api.z-api.io/instances/integrator/on-demand/batch-delete \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"instances": [
{
"id": "<string>",
"token": "<string>"
}
]
}
'import requests
url = "https://api.z-api.io/instances/integrator/on-demand/batch-delete"
payload = { "instances": [
{
"id": "<string>",
"token": "<string>"
}
] }
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({instances: [{id: '<string>', token: '<string>'}]})
};
fetch('https://api.z-api.io/instances/integrator/on-demand/batch-delete', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.z-api.io/instances/integrator/on-demand/batch-delete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'instances' => [
[
'id' => '<string>',
'token' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.z-api.io/instances/integrator/on-demand/batch-delete"
payload := strings.NewReader("{\n \"instances\": [\n {\n \"id\": \"<string>\",\n \"token\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.z-api.io/instances/integrator/on-demand/batch-delete")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"instances\": [\n {\n \"id\": \"<string>\",\n \"token\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.z-api.io/instances/integrator/on-demand/batch-delete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"instances\": [\n {\n \"id\": \"<string>\",\n \"token\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_bodyOverview
Method used to delete several instances linked to your account in a single request. To delete a single instance, use Deleting an instance.To use Partner endpoints, provide the Partner Token in the Authorization field using the following format:
Bearer <Partner-Token>It is not necessary to send the Client-Token in these requests.Send at most 100 instances per request. For larger volumes, split the operation into several calls.
Each instance in the list is evaluated individually. A rejected instance does not prevent the others from being deleted: the response reports the outcome of each one.
Eligibility rules
An instance is only deleted when it meets all of the conditions below:- It is disconnected from WhatsApp and from the phone.
- Its subscription is canceled. Paid instances, pending ones, ones with a pending bank slip, ones in the cancellation process, or ones in payment retry are not eligible.
- It is not in trial. A trial must expire naturally or be canceled first.
- The 40-day grace period counted from the subscription cancellation date has already passed.
Attributes
Header
string
required
Partner token in the
Bearer <Partner-Token> formatRequired
array
required
Request Body
{
"instances": [
{
"id": "instanceId",
"token": "instanceToken"
}
]
}
Response
200
Theresults field has one entry per instance sent, in the same order as the request.
{
"total": 3,
"deleted": 1,
"rejected": 2,
"results": [
{
"id": "3C7A1B2C3D4E5F6A",
"status": "deleted",
"type": null,
"reason": null
},
{
"id": "3C7B2C3D4E5F6A7B",
"status": "rejected",
"type": "INSTANCE_IN_GRACE_PERIOD",
"reason": "Cannot delete instance because it is still in the grace period of 40 days after cancellation"
},
{
"id": "3C7C3D4E5F6A7B8C",
"status": "rejected",
"type": "INSTANCE_NOT_FOUND",
"reason": "Instance not found"
}
]
}
Rejection reasons
Each rejected item has atype that identifies the rule that blocked the deletion.
| type | When it happens |
|---|---|
INSTANCE_STILL_CONNECTED | The instance is still connected to WhatsApp or to the phone. |
INSTANCE_IS_TRIAL | The instance is in trial. The trial must expire or be canceled first. |
INSTANCE_NOT_ELIGIBLE | The subscription is still active or is not canceled. |
INSTANCE_IN_GRACE_PERIOD | The instance was canceled less than 40 days ago. |
INSTANCE_PAYMENT_STATUS_MISSING | The payment status of the instance could not be determined. |
INSTANCE_NOT_FOUND | No instance exists for the given id and token pair. |
INTEGRATION_ERROR | Failure while communicating with the payment provider. |
INTERNAL_ERROR | Unexpected failure while deleting the instance. |
400
The instance list was empty or above the limit of 100 per request.{
"message": "Maximum of 100 instances per batch"
}
401
The Authorization header was not sent or the Partner Token is invalid.{
"message": "Authorization token is empty"
}