Deleting an instance
curl --request DELETE \
--url https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete \
--header 'Authorization: <authorization>'import requests
url = "https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete"
headers = {"Authorization": "<authorization>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: '<authorization>'}};
fetch('https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/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/{instanceId}/token/{token}/integrator/on-demand/delete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_bodyPartners
Deleting an instance
Deletes an instance linked to your integrator partner account
DELETE
/
instances
/
{instanceId}
/
token
/
{token}
/
integrator
/
on-demand
/
delete
Deleting an instance
curl --request DELETE \
--url https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete \
--header 'Authorization: <authorization>'import requests
url = "https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete"
headers = {"Authorization": "<authorization>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {Authorization: '<authorization>'}};
fetch('https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/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/{instanceId}/token/{token}/integrator/on-demand/delete",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "<authorization>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.z-api.io/instances/{instanceId}/token/{token}/integrator/on-demand/delete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_bodyOverview
Method used to delete an instance linked to your account. To delete several at once, use Deleting instances in bulk.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.Deletion is permanent and cannot be undone.
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 payment status is pending, trial, or canceled. Paid instances, ones with a pending bank slip, ones in the cancellation process, ones in payment retry, or ones without a defined payment status are not eligible.
- If it is pending, it has no pending subscription. Cancel the subscription before deleting the instance.
Attributes
Header
string
required
Partner token in the
Bearer <Partner-Token> formatPath
string
required
Your instance ID. Available in the Z-API panel under Instances.
string
required
Your Z-API instance token.
Response
204
The instance was deleted. The response has no body.403
The instance does not meet the eligibility rules. Thetype field identifies the rule that blocked the deletion and the message field describes the reason.
{
"type": "INSTANCE_HAS_ACTIVE_SUBSCRIPTION",
"message": "Cannot delete instance because it has a pending subscription. Cancel the subscription first"
}
| type | message | When it happens |
|---|---|---|
INSTANCE_STILL_CONNECTED | Cannot delete instance because it is still connected to WhatsApp or phone | The instance is still connected to WhatsApp or to the phone. Disconnect it before deleting. |
INSTANCE_PAYMENT_STATUS_MISSING | Cannot delete instance because payment status is unknown | The instance has no defined payment status. |
INSTANCE_NOT_ELIGIBLE | Cannot delete instance because it is still active | The payment status is not pending, trial, or canceled (for example: paid, pending bank slip, in the cancellation process, or in payment retry). |
INSTANCE_HAS_ACTIVE_SUBSCRIPTION | Cannot delete instance because it has a pending subscription. Cancel the subscription first | The instance is pending and has a pending subscription. Cancel the subscription before deleting. |
401
The Authorization header was not sent or the Partner Token is invalid.{
"message": "Authorization token is empty"
}
404
No instance exists for the giveninstanceId and token pair.
{
"message": "Instance not found"
}